[英]Selenium Webdriver clickAndHold() error on Firefox
I try to select multiple options from list but it does not select particular option it select from first choose options to last choose option and give some error like: 我尝试从列表中选择多个选项,但是它没有选择特定的选项,而是从“首先选择”选项中选择了“最后选择”选项,并给出如下错误:
Cannot perform native interaction: Could not get node for element - cannot interact 无法执行本机交互:无法获取元素的节点-无法交互
My code is looks like 我的代码看起来像
WebDriver driver=new FirefoxDriver();
driver.get("http://jqueryui.com/selectable/");
driver.manage().window().maximize();
driver.switchTo().frame(driver.findElements(By.tagName("iframe")).get(0));
WebElement multiSelectDropDown=driver.findElement(By.className("ui-selectable"));
List<WebElement> dropdownlists = multiSelectDropDown.findElements(By.tagName("li"));
Actions builder=new Actions(driver);
builder.clickAndHold(dropdownlists.get(0)).
clickAndHold(dropdownlists.get(4)).click()
.build().perform();
Can any one tell me why this is not working is there any problem in my code. 谁能告诉我为什么这样不起作用,我的代码是否有任何问题。
I think you need to change this 我认为你需要改变这个
builder.clickAndHold(dropdownlists.get(0)).
clickAndHold(dropdownlists.get(4)).click()
.build().perform();
This should be looks like 这应该看起来像
builder.clickAndHold(dropdownlists.get(0)).moveToElement(dropdownlists.get(4)).
release().build().perform();
because in real world click the mouse and drag to the other element so moveto another element and then release the mouse. 因为在现实世界中,单击鼠标并拖动到另一个元素,所以移动到另一个元素,然后释放鼠标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.