How do you get all the values from Drop Down list?
Answers were Sorted based on User's Feedback
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 ? | 10 Yes | 0 No |
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 |
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 ? | 5 Yes | 0 No |
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 ? | 1 Yes | 0 No |
Answer / brahmi
it selcetd by using selectbyivisuble test,selectby index,selectbyvalue
| Is This Answer Correct ? | 3 Yes | 4 No |
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 |
Please explain what are the different types of locators in selenium?
How can you find if an element in displayed on the screen?
How to handle dropdowns in selenium?
what is mutation testing, Difference between system and End to End testing,Give examples of bug having high priority but low severity except spelling mistakes and logo symbol.
What is regular expressions? How you can use regular expressions in selenium?
What are the different methods to refresh a web page in webdriver?
What is the alternative to driver.get() method to open an url using selenium webdriver?
What do we mean selenium selenium 1 and 2?
What is object repository? How can we create an object repository in selenium?
What is page factory?
How can you fetch an attribute from an element? How to retrieve typed text from a textbox?
What happens if I run this command. Driver.get(“www.softwaretestingmaterial.com”) ;