【发布时间】:2017-10-29 11:37:15
【问题描述】:
我必须从https://www.parcelhero.com 的下拉列表中选择一个国家,但是当我使用下面的代码时,有时它有时不起作用,给出 Element not found(xpath("//*[@id=' dvQuoteFrom']/div/button"))
driver.findElement(By.xpath("//*[@id='dvQuoteFrom']/div/button")).click();
Thread.sleep(4000);
WebElement txt = driver.findElement(By.xpath("html/body/div[14]/div/div/input"));
txt.sendKeys("Great Britain");
List <WebElement> InnerDropdown1 =driver.findElements(By.xpath("//*[@class='active']"));
for(WebElement option1 : InnerDropdown1)
{ System.out.println(option1.getText());
if(option1.getText().contains("Great Britain")) {
option1.click();
break;
}
}
当我使用 WebElement txt = driver.findElement(By.className("bs-searchbox"));然后我也可以找到元素错误。
请帮我从国家/地区下拉列表中选择我喜欢的国家/地区?
【问题讨论】:
标签: select selenium-webdriver drop-down-menu bootstrapping