@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//}
答案 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;
}
}