I have a situation where I had to handle drop down and click the drop down to select some values. There are two drop down in same page and one from the next page total three drop downs, they 3 have the same xpath. The xpath is giving below.

  • 1
    The Xpaths are not the same. Please explain better what is the problem. And add the HTML of the page.
    – Mate Mrše
    Commented Jul 24, 2019 at 13:21

1 Answer 1


Selenium provides a wrapper class to work with dropdowns - Select:

WebElement dropdownElement = driver.findElement(By.id("myDropdown"));
Select dropdown = new Select(dropdownElement);

And you can select things by text or position:

dropdown.selectByVisibleText("Option 1");

You can find more info on this class here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.