Hey there! any question in your mind? Ask It Now!.

Popular Categories

Get selected option from a drop-down in selenium webdriver

0 votes
asked in Software Testing by anonymous

Hi Please share the method for getting selected value from a drop-down.

My HTML is :


<select style="width: 85px;" name="right_yesorno" id="right_yesorno80175">
                                 <option value="Yes">Yes</option>
                                 <option value="No" selected="selected">No</option>

I am using Python for the same , if possible please share in JAVA also .

1 Answer

+1 vote
answered by anonymous


Using getattibute we can get the selected option value and we can assert that option using assertions

type_select = Select(self.driver.find_element_by_id("right_yesorno80175"))
   for option in type_select.options:
        if option.get_attribute("selected"):
            print option.text

Related Questions

+1 vote
1 answer 544 views
+2 votes
1 answer 1,241 views
0 votes
1 answer 6,346 views
+2 votes
1 answer 2,490 views
+1 vote
1 answer 2,239 views
+5 votes
7 answers 14,590 views
+13 votes
1 answer 117 views

Not a Member yet?

Ask to Folks Login

My Account
1058 Folks are online
69 members and 989 guest online
Your feedback is highly appreciated