0 votes
in Selenium by
How to select a value from a dropdown in Selenium WebDriver?

1 Answer

0 votes
by

Select class in WebDriver is used for selecting and deselecting options in a dropdown.

The objects of Select type can be initialized by passing the dropdown webElement as a parameter to its constructor.

WebElement testDrop = driver.findElement(By.id("testingDropdown"));  

Select dropdown = new Select(testDrop);

WebDriver offers three ways to select from a dropdown:

selectByIndex: Selection based on index starting from 0

   dropdown.selectByIndex(5);

selectByValue: Selection based on value

   dropdown.selectByValue(“Books”);

selectByVisibleText: Selection of option that displays text matching the given argument

   dropdown.selectByVisibleText(“The Alchemist”);

Related questions

0 votes
asked Jan 9 in Selenium by sharadyadav1986
0 votes
asked Jan 30, 2020 in Selenium by Deepanshu Burreja
...