无法选择显示在下拉菜单'org.openqa.selenium.NoSuchElementException:'中

时间:2013-09-28 14:34:40

标签: selenium-webdriver

@Being初学者,我被困在下面,因为我已经尝试了一整天,但无法从下拉菜单中选择。

输入文字,显示下拉菜单选择一个值。

我正在使用的参考网站是www.irctc.co.in ...仅供测试

在我的最后使用eclispe java

driver.findElement(By.xpath("//input[@name='stationFrom']")).sendKeys("PUN");
Select test = new Select(driver.findElement(By.xpath("//ol[@id
    ='no_0a_autocomplete_list']/li/span[text()='(PUNE)']")));

当我尝试检查firebug中的select xpath时,它会显示正确的路径,即在输入PUN之后。但是当测试运行时它会失败,并显示错误:

org.openqa.selenium.NoSuchElementException: no such element
  (Session info: chrome=29.0.1547.76)
  (Driver info: chromedriver=2.3,platform=Windows NT 6.2 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 29 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:32:38'
System info: os.name: 'Windows 8', os.arch: 'x86', os.version: '6.2', java.version: '1.7.0_17'

我在这个问题上尝试了解决方案: Need to select drop down value using xpath in Selenium Webdriver,但它不起作用。

1 个答案:

答案 0 :(得分:0)

解决方案如下 driver.manage()。timeouts()。implicitlyWait(30,TimeUnit.SECONDS); driver.findElement(By.xpath( “//输入[@名称= 'stationFrom']”))的SendKeys( “DEL”)。 driver.findElement(By.xpath( “// * [@ id中= 'no_0a_autocomplete_list'] /锂[8]”))上单击();