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 547 views
+2 votes
1 answer 1,263 views
0 votes
1 answer 7,107 views
+2 votes
1 answer 2,548 views
+1 vote
1 answer 2,250 views
+5 votes
7 answers 14,605 views
+13 votes
1 answer 117 views

Not a Member yet?

Ask to Folks Login

My Account
639 Folks are online
86 members and 553 guest online
Your feedback is highly appreciated