无法对<list web =“”element =“”>执行点击操作以获取selenium </list>

时间:2013-10-01 18:14:41

标签: selenium-webdriver

@Friends我是初学者级别所以引导我,如果xpath正确,请告诉我

<ol `id ="no_0a_autocomplete_list" class="autocomplete_list" style..">  
<li class="item current_item" onselect="this.text.value ='DELHI (DLI)'; ">  
<li class="item" onselect="enter code herethis.text.value ='DELHI (DLI)'; ">  
<span>(DLI)</span>DELHI</li>

Selenium Code

WebElement OlElement= driver.findElement(By.xpath("//*[@id='no_0a_autocomplete_list']"));   
List<WebElement> Str= OlElement.findElements(By.tagName("/li/span[text()='(DLI)']"));   
for(WebElement testlist : Str)
{ // Perform click//}

1 个答案:

答案 0 :(得分:0)

ListWebElement examples = driver.findElements(By.xpath("//*@id='no_0a_autocomplete_list']/li"));

for (WebElement option: examples) 
{ 
    if ("value".equals(option.getText())) 
    {
         option.click();
         break;
    }       
}