How to select a value from Dropdown in Selenium ? - TestingQ.com

-->Exclusive Portal for Testing Jobs

How to select a value from Dropdown in Selenium ?

We can select a Value from Drop down primarily in 3 ways, by using below methods.

  • selectByValue
  • selectByVisibleText
  • sectByIndex

1) selectByValue:

Select drpDwn = new Select(driver.findElement(By.Id("dropdown-id")));

drpDwn.selectByValue("value");


2) selectByVisibleText:

Select drpDwn = new Select(driver.findElement(By.Id("dropdown-id")));

drpDwn.selectByVisibleText("Red");


3) selectByIndex:

Select drpDwn = new Select(driver.findElement(By.Id("dropdown-id")));

drpDwn.selectByIndex(3);


To receive daily posted JOBS and Interview Questions
Just enter your email address below and click 'Submit'

Enter your email address:



Make sure to activate your subscription by clicking on the activation link sent to your email

No comments:

Post a Comment