Multi-Select From Drop Down Menu Using Select Class


public class Dropdownmultiselect {


@Test
public void test1() {


WebDriver driver = new FirefoxDriver();

        //Go to any url where u can find drop down menu
driver.get("Any site url");

        //get the locators from drop down menu
Select dropdown = new Select(driver.findElement(By.id("")));

dropdown.selectByVisibleText("select any name from drop down menu");
dropdown.selectByIndex(3);
List<WebElement> elements=dropdown.getAllSelectedOptions();
         for(WebElement element:elements){
        System.out.println(element.getText());
        }



}

}


No comments:

Post a Comment