Working with Dropdown using Selenium Webdriver
Just wrap your WebElement into Select Object as shown below
Select dropdown = new Select(driver.findElement(By.id("identifier")));
Once this is done you can select the required value in 3 ways. Consider an HTML file like this
Below is the drop down :)
Now to identify dropdown do
Select dropdown = new Select(driver.findElement(By.id("designation")));To select its option say 'Programmer' you can do
dropdown.selectByVisibleText("Programmer ");or
dropdown.selectByIndex(1);or
dropdown.selectByValue("prog");
No comments:
Post a Comment