简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM