saba
saba

Reputation: 539

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.

Upvotes: 0

Views: 960

Answers (1)

user900481
user900481

Reputation:

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.

Upvotes: 1

Related Questions