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

Answers were Sorted based on User's Feedback



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

Answer / 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 ?    8 Yes 0 No

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

Answer / raam

----------------------------------------------
Select cel=new Select(driver.findElement(By.id("name"))

cel.selectByVisibleText("state")
---------------------------------------
instead of selectByVisibleText can use-

selectByindex()
getoptions()---used to store all options inside drop down

Is This Answer Correct ?    8 Yes 3 No

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

Answer / p sureshchowdary

Select dropdown=new Select(d.findElement(By.id("month")));
List<WebElement> list=dropdown.getOptions();
for(WebElement we:list) {
System.out.println(we.getText());
}

Is This Answer Correct ?    4 Yes 0 No

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

Answer / chetan phani.j

If the dropdown list box is developed by using Select tag then we can use Select class.
ex:
WebElement adrs=d.findelementBy.id();
Select sal=new Select(adrs);

Is This Answer Correct ?    0 Yes 0 No

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

Answer / brahmi

it selcetd by using selectbyivisuble test,selectby index,selectbyvalue

Is This Answer Correct ?    3 Yes 4 No

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

Answer / raj

(new WebDriverWait(driver, 60)).until(new ExpectedCondition<WebElement>() {
public WebElement apply(WebDriver newDriver) {
return newDriver.findElement(By.id("BlogArchive1_ArchiveMenu"));
}
});

Is This Answer Correct ?    0 Yes 5 No

Post New Answer



More Selenium Interview Questions

How is driver.close()command different from driver.quit command?

0 Answers  


How we handle pop-up web-based ?

0 Answers  


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

6 Answers   HCL,


What is the syntax of finding elements by id using css selector?

0 Answers  


How to switch between multiple windows in selenium?

0 Answers  






Write a code snippet to perform mouse hover in webdriver.

0 Answers  


What are the different types of waits available in webdriver?

0 Answers  


How can we find the value of different attributes like name, class, value of an element?

0 Answers  


How do you handle alert popup?

0 Answers  


How you can use “submit” a form using selenium?

0 Answers  


How do you Upload or Download a File in Web Application?

2 Answers   HCL,


Explain me what are the main advantages of selenium?

0 Answers  






Categories