How to select value in a dropdown?

Answer

Value in the drop down can be selected using WebDriver’s Select class.

Syntax:

selectByValue:
Select selectByValue = newSelect(driver.findElement(By.id(“SelectID_One”)));
selectByValue.selectByValue(“greenvalue”);

selectByVisibleText:
Select selectByVisibleText = new Select (driver.findElement(By.id(“SelectID_Two”)));
selectByVisibleText.selectByVisibleText(“Lime”);

selectByIndex:
Select selectByIndex = newSelect(driver.findElement(By.id(“SelectID_Three”)));
selectByIndex.selectByIndex(2);

All selenium Questions

Ask your interview questions on selenium

Write Your comment or Questions if you want the answers on selenium from selenium Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---