How can I select an item Option 3 in drop down as below?

    <span class="k-widget k-dropdown k-header form-control required" style="padding: 0px;" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="true" tabindex="0" aria-owns="assignee_listbox" aria-disabled="false" aria-readonly="false" aria-busy="false" aria-activedescendant="assignee_option_selected">
    <span class="k-dropdown-wrap k-state-default" unselectable="on">
    <select id="assignee" class="form-control required" style="padding: 0px; display: none;" name="assignedUserId" data-role="dropdownlist" title="">
        <option value="28941">Option 1</option>
        <option value="28938">Option 2</option>
        <option value="28940">Option 3</option>
        <option value="28942">Option 4</option>
        <option value="28943" selected="selected">Option 5</option>
        <option value="28939">Option 6</option>

I tried to select the option 3 on drop-down list, below is my code:

public Page selectAsignee(String asignee){
            WebElement dropdownAsignee = connector.waitForControl(SBConstant.XPATH,dropdownAssignee,3);
            // My xPath is //select[@id='assignee']
            Select select = new Select(dropdownAsignee);
            select.selectByVisibleText("Option 3");
            return this;

        }catch (StaleElementReferenceException s){
        return this;

But it's unable to select option 3 although web driver can detect the select with id ="assignee". After run this code, it throws the error like this:

org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with

I'm hoping someone can point out an error on my part that will make this all better.


2 Answers 2


https://stackoverflow.com/questions/19637507/java-webdriver-element-not-visible-exception suggest to Click the Select first to open the dropdown.

The click will do two things

  • Try to scroll to the element to get it in the current view port
  • Open the dropdown, now the options are also visible

Implement Explicit wait , Check below :

 WebElement Element = (new WebDriverWait(driver, 30))

Add above code just before your selenium find dropdown. It will wait till dropdown loads with values.

  • I would expect the waitForControl function todo something similar on the third line of the example. Jul 20, 2015 at 9:14
  • @NielsvanReijmersdal - Might be , I am not familiar with that kind of wait so just suggested this to OP. Jul 20, 2015 at 9:30
  • I think its a custom wrapper wait function written by the op. Maybe we should ask to show us that code too :) Jul 20, 2015 at 9:37
  • Yep , You are right..:) Jul 20, 2015 at 9:42
  • Yes, in the function waitforControl : <code> WebElement element = (new WebDriverWait(driver, second)) .until(ExpectedConditions.presenceOfElementLocated(By.Xpath("xpaht"))); </code>
    – scorpion
    Jul 20, 2015 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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