![](/img/trans.png)
[英]Mouse clickAndHold() not working properly on Firefox Using Selenium Webdriver
[英]Selenium Webdriver clickAndHold() error on Firefox
我嘗試從列表中選擇多個選項,但是它沒有選擇特定的選項,而是從“首先選擇”選項中選擇了“最后選擇”選項,並給出如下錯誤:
無法執行本機交互:無法獲取元素的節點-無法交互
我的代碼看起來像
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();
誰能告訴我為什么這樣不起作用,我的代碼是否有任何問題。
我認為你需要改變這個
builder.clickAndHold(dropdownlists.get(0)).
clickAndHold(dropdownlists.get(4)).click()
.build().perform();
這應該看起來像
builder.clickAndHold(dropdownlists.get(0)).moveToElement(dropdownlists.get(4)).
release().build().perform();
因為在現實世界中,單擊鼠標並拖動到另一個元素,所以移動到另一個元素,然后釋放鼠標。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.