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);
No comments:
Post a Comment