Search code examples
javaseleniumdropdown

Selecting from drop down list Selenium Java


This is part of website code related to this question This is part of website code related to this question

I have trouble here to identify drop down list, actually i cant find a xpath of this drop down element and select first (and only) element from drop down list.

driver.findElement(By.xpath("//input[@placeholder='Assign to a member']"));

This is my xpath for field, but nothing happens when start working. Anyone to suggest me how to approach to this issue.


Solution

  • in Java, you need to create a select element to choose the options of the select.

    The code will be somenthing like:

    WebElement element = driver.findElement(By.xpath("//input[@placeholder='Assign to a member']"));
    
    String option = "Option value you want to select";
    Select select = new Select(element);
    select.selectByVisibleText(option);