How to select an option from drop down using Selenium WebDriver C#?

How to select an option from drop down using Selenium WebDriver C#?

To select an option from a drop-down menu in C#, you can find the element directly using its XPath. The way "select" tags work is convenient for locating elements as you do not need to click on menu first to see the list of options as you would as a user.

sundayOption = self.driver.find_element_by_xpath("//option[.='Sunday']");
sundayOption.click();

Leave a reply

Your email address will not be published. Required fields are marked*

CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
1 + 1 =

Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.