How to select all options in a drop down using selenium.

Test Automation 0 Comment 56

To get all  the options in a dropdown,we have a method called getoptions() in selenium. By using this method we can retrive all the options in dropdown.

Select s= new select(driver.findElement(By.name(“………….”));

//get list of options

list<webElement> x= s.getOptions();

 

y=x.size();

//print size of the list

system.out.println(y);

//print each and everyone element in dropdown list

for(int i=0;i<=y;i++)

{

L=s.get(i).getText();

system.out.println(L);

}

Author

Related Articles

Leave a comment

You must be logged in to post a comment.

© 2016 4frienz. Powered By Flowers

Back to Top