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

+1 vote

Sep 30, 2019 in Selenium by Mounika
• 130 points
10,662 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,140 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 6, 2020 in Selenium by Sri
• 3,190 points
18,443 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
936 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,520 points
81,576 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,140 points
1,241 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,500 points
7,920 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 3, 2019 in Selenium by Anvi
• 14,150 points
10,469 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 5, 2019 in Selenium by Anvi
• 14,150 points
19,867 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP