How to select a drop-down menu value with Selenium using Java?

How to select a drop-down menu value with Selenium using Java?

To select an option from a drop-down menu in Python, 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.

WebElement option = driver.findElement(By.xpath("//option[.='Sunday']"));

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.
3 + 3 =

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