How to handle dropdowns in Selenium?

How to handle dropdowns in Selenium?

Hello Rhian-lewis,

You can do this by using Select class-

Select countriesDropDown = new Select(driver.findElement(By.id("countries")));
dropdown.selectByVisibleText("India");
//or using index of the option starting from 0
dropdown.selectByIndex(1);
//or using its value attribute
dropdown.selectByValue("Ind");