Handling of HTML Dropdown Using Selenium WebDriver - H Y R Tutorials

Handling of HTML Dropdown Using Selenium WebDriver

Share This
hyrtutorials

This video shows how we can handle dropdowns using Selenium WebDriver.



For handling dropdowns selenium is providing one class called "Select" which is available under package "org.openqa.selenium.support.ui".

 

The select class is providing multiple methods to work with dropdowns, Those are as follows:

selectByIndex: Select the option at the given index.

selectByValue: Select all options that have a value matching the argument.

selectByVisibleText: Select all options that display text matching the argument.

deselectAll: Clear all selected entries.

deselectByIndex: Deselect the option at the given index.

deselectByValue: Deselect all options that have a value matching the argument.

deselectByVisibleText: Deselect all options that display text matching the argument.

getAllSelectedOptions: Returns all selected options belonging to this select tag.

getFirstSelectedOption: Returns the first selected option in this select tag.

getOptions: Returns all options belonging to this select tag.