enter image description here

First time here. I've got an issue you might be able to help with. Working on chrome webdriver automation, there's a dropdown menu that's toggled with a click. I need to be able to select list items. Here is the code for the menu.

 <button type="button" class="multiselect dropdown-toggle btn btn-default" data-toggle="dropdown" title="None selected" aria-expanded="true"><span class="multiselect-selected-text">None selected</span> <b class="caret"></b></button>

class="multiselect-container dropdown-menu"

My attempts to interact with it through the following have failed.

new Select(driver.findElementByXPath("//button[@type='button']")).selectByVisibleText("TEST");

If you need any more information please ask, not familiar with what might be required. Many thanks

UPDATE; Thanks for the replies. "Select by option name" doesn't seem to work. Using that code with my xpath i get the following

org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "button"

"Select by option value" gives the same error.

I found the xpath and class via css using the chrome selenium IDE, however maybe it's incorrect as the below fails to toggle the dropbox and gives the following error. Also i'm in the correct iframe as i can interact with another element.


org.openqa.selenium.ElementNotVisibleException: element not visible

Might i be referencing the element in an incorrect way? Many thanks

update2: I feel like i might be getting close.


 unknown error: Element <select class="userdropdown" id="ptp_sl" multiple="multiple">...</select> is not clickable at point 
  • 3
    Possible duplicate of How do I work with dropdowns in Selenium Webdriver?
    – Jonnyboy
    Commented Jun 18, 2018 at 8:08
  • Good question. Does the link @Jonnyboy's provided give you an answer?
    – dvniel
    Commented Jun 18, 2018 at 10:38
  • Can you please share the code which you are trying and the error which you are getting.
    – shanila
    Commented Jun 18, 2018 at 11:53
  • Hi guys, replies in the OP. Commented Jun 18, 2018 at 23:27

1 Answer 1


The below code will locate the dropdown and prints the list of options present in the dropdown.Check whether the below mentioned first two line of code is locating your dropdown.And I have added next few lines to check whether all the dropdown options are displayed.

WebElement we = driver.findElement(By.xpath("//select[@class='userdropdown']"));
Select dropdown = new Select(we);
List<WebElement> alloptions = dropdown.getOptions();
for(WebElement option:alloptions)
  • Hi mate, thanks for your reply. Didn't work initially but made edits to findbyId and all the users were printed. Absolutely brilliant. All of the options print in the Console. What's the final piece of the puzzle to select them in the combobox? Thanks EDIT: They were being selected by didn't update the combobox text. Many thanks ! Commented Jun 19, 2018 at 4:39
  • @Lewis just try by adding the code dropdown.selectByVisibleText("your text in the combobox"); below the Select dropdown code.Just comment out if it works.....
    – shanila
    Commented Jun 19, 2018 at 4:49

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.