By using Select class we can do this. Select class having different methods to select the dropdown value.
Example:- selectByIndex()
- selectByValue()
- selectByVisibleText()
WebElement element= driver.findElement(By.xpath("xpath of city dropdown"));
Select dropdownvalue = new Select(element);
dropdownvalue.selectByIndex(1); // It will select the 2nd drop down value- Jaipur
dropdownvalue.selectByValue("Jaipur");
dropdownvalue.selectByVisibleText("Jaipur");
No comments:
Post a Comment