How do you get all the values from Drop Down list?

Answer Posted / rupesh

WebElement sel = myD.findElement(By.name("dropdown_name"));
List<WebElement> lists = sel.findElements(By.tagName("option"));
for(WebElement element: lists)
{
String var2 = tdElement.getText();
System.out.println(var2);
}

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can we find all the links on a web page?

554


How to handle alerts in selenium?

514


Explain how to iterate through options in test script?

700


How to print Duplicate values in Drop Down List

509


What are the different components of the selenium?

478






How to change the url on a webpage using selenium web driver?

473


What selenese command and argument can be used to transfer the value of a javascript variable into a side variable?

4245


What do you know about Selenese?

545


How many types of waits in selenium?

472


Explain what does @test(invocationcount=?) And @test(threadpoolsize=?) Indicate.

3747


How can we check if an element is getting displayed on a web page?

509


what is your approach clicking all the links which are available on the page?

492


What are the regular expression patterns available in selenium?

501


How to get the number of frames on a page?

534


How do you send enter/tab keys in webdriver?

484