how to display all items in the list in the drop down

+1 vote

Sep 29, 2019 in Selenium by Mounika
• 130 points
4,956 views

2 answers to this question.

0 votes

Hey Mounika, you can checkout this thread to resolve your problem: https://www.edureka.co/community/51833/how-get-options-dropdown-webpage-using-selenium-webdriver

answered Sep 30, 2019 by Abha
• 28,040 points
+1 vote

Try using following code: 

 WebElement dropdown = driver.findElement(By.id("id_dropdown"));

 Select list = new Select(dropdown);

 List<WebElement> dropdown_list = list.getOptions();

 for (int i = 0; i < dropdown_list.size(); i++) {

   String dropdown_value = dropdown_list.get(i).getText();

   System.out.println("dropdown values are " + dropdown_value);

 }
answered Sep 30, 2019 by Anvi
• 14,150 points
What if the select class object is declared as static?
Hey, have you tried @Abha's solution?

Related Questions In Selenium

0 votes
2 answers

How to scroll the Page up or down in Selenium WebDriver? (using java)

JavascriptExecutor jsx = (JavascriptExecutor)driver; jsx.executeScript("window.scrollBy(0,555)", ""); or Action classes ...READ MORE

answered Sep 5, 2020 in Selenium by Sri
• 3,050 points
15,160 views
0 votes
1 answer

How to choose from a drop-down in Selenium 2?

You can probably use the 'Select' class ...READ MORE

answered Apr 24, 2018 in Selenium by king_kenny
• 3,710 points
489 views
0 votes
1 answer
0 votes
3 answers

How to print text from a list of all web elements with same class name in Selenium?

Try using List <WebElement> to access all similar elements ...READ MORE

answered Dec 16, 2020 in Selenium by Roshni
• 10,480 points
33,505 views
+1 vote
1 answer

How to handle a combobox which when clicked open in new window with list of items(to be clicked) in selenium java ?

@Pavithra, you can try using following commands ...READ MORE

answered Oct 29, 2019 in Selenium by Abha
• 28,040 points
455 views
+1 vote
1 answer

How to handle drop downs using Selenium WebDriver in Java

First, find an XPath which will return ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,520 points
5,578 views
0 votes
1 answer

How to capture the text from Alert Message in Selenium Webdriver?

Hello @Farhan, you can use getText() method ...READ MORE

answered Jul 2, 2019 in Selenium by Anvi
• 14,150 points
7,433 views
0 votes
1 answer

How to scroll up/down a page using Actions class in Selenium?

Hi Naetik, you can use Actions class ...READ MORE

answered Jul 4, 2019 in Selenium by Anvi
• 14,150 points
12,975 views