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

If the test case frame contains several test cases, how can one execute just the selected one of those test cases?

484


Can you write the code to double click an element in selenium?

514


What are the different types of locators in Selenium?

531


Explain what is group test in testng?

497


Explain what is the main difference between web-driver and rc?

456






Explain me how many types of webdriver apis are available in selenium?

493


What is automation testing?

501


How would one access the value of a side variable named name from within a javascript snippet used as the argument to a selenese command?

457


List some advantages of test automation?

536


How do you send enter/tab keys in webdriver?

489


Mention what is desired capability? How is it useful in terms of selenium?

490


Which is the command used for displaying the values of a variable into the output console or log?

498


How can we create a data-driven framework using testng?

472


List some scenarios which we cannot automate using selenium webdriver?

481


How to check the checkbox or radio button is selected?

488