Time for action – selecting multiple items on a select item - Selenium

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:

  3. Run the test. You should see the following:

What just happened?

We have just successfully done a multi-select. This can be useful for testing forms that allow users to select multiple items. The same principle can be used if you needed to interact with anything that required both the keyboard and the mouse to be used at the same time.

Holding the mouse button down while moving the mouse

Canvas applications are becoming one of the most used HTML5 components to be added to applications. One of the nice things that we can do with it is draw pictures on the page just by clicking and holding down the mouse.

From the automation point of view, this would appear to be extremely difficult. We have commands like click() and we know that we can move an element by a specific offset but a click() doesn't do what we do.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Selenium Topics