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

Which of the selector ID, name, XPath or CSS should I use?

515


What is object repository? How can we create object repository in selenium?

480


Mention what is the difference between selenium and sikuli?

671


How to scroll down to a particular element?

3162


What is the selenium's recording language?

545






What is the difference between selenium ide, selenium rc, and webdriver?

523


What are some advantages of selenium?

520


Explain how you can find broken images in a page using selenium web driver?

471


What are the advantages of rc?

537


How do perform drag and drop using webdriver?

530


What are some advantages of selenium grid?

533


How can you handle network latency using selenium?

510


Write a code snippet to perform mouse hover in webdriver.

485


How to pause a test execution for 5 seconds at a specific point?

542


How do you read data from excel?

510