O'Reilly logo

Selenium 2 Testing Tools Beginner's Guide by David Burns

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – selecting multiple items on a select item

A number of forms nowadays ask users to select a number of items from a list. For me a good example is the Advanced Search on Bugzilla. You can see an example at https://bugzilla.mozilla.org/query.cgi?format=advanced. In Selenium RC, selecting multiple items was impossible. Using the standard clicking and typing with Selenium WebDriver we will not be able to do this either, however we can get around this with the actions API.

  1. Open up inteliij and create a new Selenium WebDriver project.
  2. Create a new class and a new test with the following code:
    WebDriver driver = new FirefoxDriver(); ter.co.uk/multi-select.html"); Actions builder = new Actions(driver); WebElement select = driver.findElement(By.tagName("select")); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required