RE: How to read from multiples select (drop down winndows) in the same script and store by their labels


I am trying to write a script where i can read all the drop down elements in a web page and store them by categorizing with their parent labels.

Ex: Go the the below website.

You can see “Purpose of Mortgage or Loan” as thee label to identify the first Drop Down in the same way “Type of Property” for the second drop down.

Would like to Write a script in such a way that if i print the options by label, it  should print as

Purpose of Mortgage or Loan
Home Loan
Home Mortgage
Home Mortgage Refinance
Debt Consolidation Loan
Second Mortgage

Type of Property

like this.

Can someone please help me in writing this script and shed some light on the way to achieve it.

Phani M

mannebhushan Default Asked on November 11, 2015 in Selenium WebDriver.
Add Comment
3 Answers


Use findElements(), it returns a list of WebElements.

In your case, you can use findelements on  drop-down elements.Save them in a List<WebElement> of  drop-down elements, iterate over all items in the list and get the require attribute from all elements using get attribute method and print them.

Give it a try,it’s simple.


Train Answered on November 13, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.