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

Get selected option from a drop-down in selenium webdriver

0 votes
76 views
asked in QA Automation 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>
                             </select>

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

Not a Member yet?

Answer Queue Login
131 Folks are online
0 members and 131 guest online