title: How to click combobox search dropdown in selenium?
body: <p>I want to select an item from the combobox search dropdown. </p>
  
  <p>Html Code of the website is:</p>
  
  <pre><code> &lt;div class="form-group"&gt;
   &lt;div class="row"&gt;
   &lt;div class="col-sm-6 margin-bottom"&gt;
   &lt;select id="CustomerCard_state" class="form-control m-b drop_state"                          tabindex="-1" name="CustomerCard.state" data-val-required="Please enter State"        data-val="true" style="display: none;"&gt;
   &lt;option value=""&gt;Please select state&lt;/option&gt;
   &lt;option value="AK"&gt;Alaska&lt;/option&gt;
   &lt;option value="AL"&gt;Alabama&lt;/option&gt;
   &lt;option value="AZ"&gt;Arizona&lt;/option&gt;
   &lt;option value="AR"&gt;Arkansas&lt;/option&gt;
   &lt;option value="CA"&gt;California&lt;/option&gt;
   &lt;option value="CO"&gt;Colorado&lt;/option&gt;
   &lt;option value="CT"&gt;Connecticut&lt;/option&gt;
   &lt;option value="DE"&gt;Delaware&lt;/option&gt;
   &lt;option value="FL"&gt;Florida&lt;/option&gt;
   &lt;option value="GA"&gt;Georgia&lt;/option&gt;
   &lt;option value="HI"&gt;Hawaii&lt;/option&gt;
   &lt;option value="ID"&gt;Idaho&lt;/option&gt;
   &lt;option value="IL"&gt;Illinois&lt;/option&gt;
   &lt;option value="IN"&gt;Indiana&lt;/option&gt;
   &lt;option value="IA"&gt;Iowa&lt;/option&gt;
   &lt;option value="KS"&gt;Kansas&lt;/option&gt;
   &lt;option value="KY"&gt;Kentucky&lt;/option&gt;
   &lt;option value="LA"&gt;Louisiana&lt;/option&gt;
   &lt;option value="ME"&gt;Maine&lt;/option&gt;
   &lt;option value="MD"&gt;Maryland&lt;/option&gt;
   &lt;option value="MA"&gt;Massachusetts&lt;/option&gt;
   &lt;option value="MI"&gt;Michigan&lt;/option&gt;
   &lt;option value="MN"&gt;Minnesota&lt;/option&gt;
   &lt;option value="MS"&gt;Mississippi&lt;/option&gt;
   &lt;option value="MO"&gt;Missouri&lt;/option&gt;
   &lt;option value="MT"&gt;Montana&lt;/option&gt;
   &lt;option value="NE"&gt;Nebraska&lt;/option&gt;
   &lt;option value="NV"&gt;Nevada&lt;/option&gt;
   &lt;option value="NH"&gt;New Hampshire&lt;/option&gt;
   &lt;option value="NJ"&gt;New Jersey&lt;/option&gt;
   &lt;option value="NM"&gt;New Mexico&lt;/option&gt;
   &lt;option value="NY"&gt;New York&lt;/option&gt;
   &lt;option value="NC"&gt;North Carolina&lt;/option&gt;
   &lt;option value="ND"&gt;North Dakota&lt;/option&gt;
   &lt;option value="OH"&gt;Ohio&lt;/option&gt;
   &lt;option value="OK"&gt;Oklahoma&lt;/option&gt;
   &lt;option value="OR"&gt;Oregon&lt;/option&gt;
   &lt;option value="PA"&gt;Pennsylvania&lt;/option&gt;
   &lt;option value="RI"&gt;Rhode Island&lt;/option&gt;
   &lt;option value="SC"&gt;South Carolina&lt;/option&gt;
   &lt;option value="SD"&gt;South Dakota&lt;/option&gt;
   &lt;option value="TN"&gt;Tennessee&lt;/option&gt;
   &lt;option value="TX"&gt;Texas&lt;/option&gt;
   &lt;option value="UT"&gt;Utah&lt;/option&gt;
   &lt;option value="VT"&gt;Vermont&lt;/option&gt;
   &lt;option value="VA"&gt;Virginia&lt;/option&gt;
   &lt;option value="WA"&gt;Washington&lt;/option&gt;
   &lt;option value="WV"&gt;West Virginia&lt;/option&gt;
   &lt;option value="WI"&gt;Wisconsin&lt;/option&gt;
   &lt;option value="WY"&gt;Wyoming&lt;/option&gt;
   &lt;/select&gt;
   &lt;div id="CustomerCard_state_chosen" class="chosen-container chosen-        container-single chosen-with-drop chosen-container-active" style="width: 100%;"   title=""&gt;
   &lt;a class="chosen-single" tabindex="-1"&gt;
   &lt;span&gt;Please select state&lt;/span&gt;
   &lt;div&gt;
   &lt;b/&gt;
   &lt;/div&gt;
   &lt;/a&gt;
   &lt;div class="chosen-drop"&gt;
   &lt;div class="chosen-search"&gt;
   &lt;input type="text" autocomplete="off" tabindex="16"/&gt;
   &lt;/div&gt;
   &lt;ul class="chosen-results"&gt;
   &lt;li class="active-result result-selected" style="" data-option-array-       index="0"&gt;Please select state&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="1"&gt;Alaska&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="2"&gt;Alabama&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="3"&gt;Arizona&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array- index="4"&gt;Arkansas&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="5"&gt;California&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-     index="6"&gt;Colorado&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-     index="7"&gt;Connecticut&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="8"&gt;Delaware&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="9"&gt;Florida&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-     index="10"&gt;Georgia&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="11"&gt;Hawaii&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="12"&gt;Idaho&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="13"&gt;Illinois&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="14"&gt;Indiana&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="15"&gt;Iowa&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="16"&gt;Kansas&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="17"&gt;Kentucky&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="18"&gt;Louisiana&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="19"&gt;Maine&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="20"&gt;Maryland&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="21"&gt;Massachusetts&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="22"&gt;Michigan&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="23"&gt;Minnesota&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="24"&gt;Mississippi&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="25"&gt;Missouri&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="26"&gt;Montana&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="27"&gt;Nebraska&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="28"&gt;Nevada&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="29"&gt;New Hampshire&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="30"&gt;New Jersey&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="31"&gt;New Mexico&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="32"&gt;New York&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="33"&gt;North Carolina&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="34"&gt;North Dakota&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="35"&gt;Ohio&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="36"&gt;Oklahoma&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="37"&gt;Oregon&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="38"&gt;Pennsylvania&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="39"&gt;Rhode Island&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="40"&gt;South Carolina&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="41"&gt;South Dakota&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="42"&gt;Tennessee&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="43"&gt;Texas&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="44"&gt;Utah&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="45"&gt;Vermont&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="46"&gt;Virginia&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="47"&gt;Washington&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="48"&gt;West Virginia&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="49"&gt;Wisconsin&lt;/li&gt;
   &lt;li class="active-result" style="" data-option-array-index="50"&gt;Wyoming&lt;/li&gt;
   &lt;/ul&gt;
   &lt;/div&gt;
   &lt;/div&gt;
   &lt;span class="text-danger drop_state-error " style="display:none;"/&gt;
   &lt;/div&gt; 
  </code></pre>
  
  <p>My selenium code is:</p>
  
  <pre><code>    WebElement select = BrowserSetup.driver.findElement(By.xpath("//div[contains(@class,'chosen-container')]"));
      select.click();
  
      List&lt;WebElement&gt; dropDowns = BrowserSetup.driver.findElements(By.className("chosen-results"));
  
      WebElement dropDownOne = dropDowns.get(0); // perform further action
      dropDownOne.click();
  </code></pre>
  
  <p>It is throwing an exception : 
  org.openqa.selenium.ElementNotVisibleException: element not visible at line :
      WebElement dropDownOne = dropDowns.get(0); dropDownOne.click();</p>
  
  <p>I have also tired to add explicit wait with following code</p>
  
  <pre><code>    WebElement select =     BrowserSetup.driver.findElement(By.xpath("//div[contains(@class,'chosen-  container')]"));
      select.click();
  
      WebDriverWait wait = new WebDriverWait(BrowserSetup.driver, 20);
      wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.className("chosen-results")));
  
      List&lt;WebElement&gt; dropDowns = BrowserSetup.driver.findElements(By.className("chosen-results"));
  
      WebElement dropDownOne = dropDowns.get(0); // perform further action
      dropDownOne.click();
  </code></pre>
  
  <p>What can I do to resolve this issue? It is working when i debug my code, but it throws exception when i run my program.</p>