Aug 22, 2019 in Selenium
Q:

How to select a value in a dropdown?

1 Answer

0 votes
Aug 22, 2019
By using Select class

WebElement mySelectElement = driver.findElement(By.name("dropdown"));

Select dropdown = new Select(mySelectElement);

dropdown.selectByVisibleText(Text);

dropdown.selectByIndex(Index);

dropdown.selectByValue(Value);

1

2

3

4

5

WebElement mySelectElement = driver.findElement(By.name("dropdown"));

Select dropdown = new Select(mySelectElement);

dropdown.selectByVisibleText(Text);

dropdown.selectByIndex(Index);

dropdown.selectByValue(Value);

Practical Example:
Click here to read more about Selenium
Click here to read more about Insurance

Related questions

0 votes
Aug 22, 2019 in Selenium
...