Free Source Code and Tutorials

Custom Search

How to select a value from a dropdown ?

We can select a value from a dropdown by using WebDriver’s Select class.


  1. selectByValue:
  2. Select selectByValue = new Select(driver.findElement(“SelectID_One”)));
  3. selectByValue.selectByValue(“greenvalue”);
  5. selectByVisibleText:
  6. Select selectByVisibleText = new Select (driver.findElement(“SelectID_Two”)));
  7. selectByVisibleText.selectByVisibleText(“Lime”);
  9. selectByIndex:
  10. Select selectByIndex = new Select(driver.findElement(“SelectID_Three”)));
  11. selectByIndex.selectByIndex(2);
  1. public Select(WebElement element)

A check is made that the given element is, indeed, a SELECT tag. If it is not, then an UnexpectedTagNameException is thrown.
Parameters:element – SELECT element to wrapThrows:UnexpectedTagNameException – when element is not a SELECT

Facebook Comments
(Visited 3 times, 1 visits today)
Share this

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked * © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!

%d bloggers like this: