log_file log_file - 7 months ago 70
Java Question

Multiple Selection Using Selenium Webdriver

I want to simulate a multiple selection scenario using Selenium webdriver, so that the user is able to select Item 1 and Item 5 (see the URL) .

URL JQuery Selectable

Right now I am trying to do this using the clickAndHold function, but when I try, it selects all the other items in between the Item 1 and Item 5.

Right now this is happening

This is happening

I want this

I want this

My code goes like this :

List<WebElement> list=driver.findElements(By.cssSelector("ol#selectable *"));
Actions act=new Actions(driver);


So the mouse is not released until it gets to the fifth item in the list, which probably is the reason for selection in between.

But If I try to not release the mouse click and select the fourth item, using this code


Then I'm getting the same output as the code above. What should I change here so the the items in between are not selected.


Since what you want is a more CTRL+click type of usage scenario, I'd recommend the following:

Actions actions = new Actions(driver)

While I've not tested this exact code, this should get you down the right path.