[英]Unable to select ajax dropdown value using selenium webdriver
I am trying to select a particular values from 2 Ajax drop down fields.First drop down option list getting open but doesn't select option, that's why second drop down list is not binding and error occurred as 我正在尝试从2个Ajax下拉字段中选择特定值。第一个下拉选项列表打开但未选择选项,这就是第二个下拉列表未绑定且发生错误的原因
org.openqa.selenium.NoSuchElementException: Unable to locate element: option[value="111"].
org.openqa.selenium.NoSuchElementException:无法找到元素:option [value =“ 111”]。
Please help me.. I am new on selenium 请帮助我..我是硒新手
Here is my code.. 这是我的代码。
HTML Block: HTML块:
This issue occurred because of Firefox browser(version 45) compatibility issue. 发生此问题是由于Firefox浏览器(版本45)兼容性问题。 I am using selenium 3.0.0-beta2 and test against Firefox 45.0.2
我正在使用硒3.0.0-beta2并针对Firefox 45.0.2进行测试
When tried geckodriver (version 0.10.0)for OS windows 10 -64 bit, it seems something not work. 在OS Windows 10 -64位上尝试geckodriver(0.10.0版)时,似乎无法正常工作。 It only works with Firefox 48 or onwards.
它仅适用于Firefox 48或更高版本。 It successfully working on chromedriver
它在chromedriver上成功工作
You can try a more specific way to interact with dropdowns in selenium. 您可以尝试一种更具体的方式来与硒中的下拉列表进行交互。 Try something like this:
尝试这样的事情:
Select dropdown = new Select(driver.findElement(By.id("cmbJob")));
dropdown.selectByValue("111");
You can even define a function for working with dropdwns: 您甚至可以定义用于dropdwns的函数:
protected void chooseOptionInSelectByValue(String selectId, String valueString) {
Select dropdown = new Select(driver.findElement(By.id(selectId)));
dropdown.selectByValue(valueString);
}
So you can use the function like this 所以你可以使用这样的功能
chooseOptionInSelectByValue("cmbJob","111");
Selenium dropdown object has many other options like selectByText, etc. Check it in the API here: https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html Selenium下拉对象还有很多其他选项,例如selectByText等。请在此处的API中进行检查: https ://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/ui/Select.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.