title: How to select dropdown menu item which is defined under <span> tag using Selenium WebDriver and C#
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="span3"&gt;
                  &lt;div&gt;
                      LSP Account&lt;br&gt;
                      &lt;span title="" class="k-widget k-dropdown k-header" unselectable="on" role="listbox" aria-haspopup="true" aria-expanded="false" tabindex="0" aria-owns="cboAccountSettings_listbox" aria-disabled="false" aria-busy="false" aria-activedescendant="7245f0ab-5ba4-4c7b-b722-6c204d700e9f" style="width: 98%;"&gt;
                      &lt;span unselectable="on" class="k-dropdown-wrap k-state-default"&gt;
                      &lt;span unselectable="on" class="k-input"&gt;Any&lt;/span&gt;
                      &lt;span unselectable="on" class="k-select"&gt;
                      &lt;span unselectable="on" class="k-icon k-i-arrow-s"&gt;select&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
                      
                      &lt;select id="cboAccountSettings" style="width: 98%; display: none;" data-value-primitive="true" data-bind="value: SWO_Id" data-role="dropdownlist"&gt;
                      &lt;option value="" selected="selected"&gt;Any&lt;/option&gt;
                      &lt;option value="SWO-ARG"&gt;SoftwareONE ARG&lt;/option&gt;
                      &lt;option value="SWO-AUS"&gt;SoftwareONE AUS&lt;/option&gt;
                      &lt;option value="SWO-BOL"&gt;SoftwareONE BOL&lt;/option&gt;
                      &lt;option value="SWO-BRA"&gt;SoftwareONE BRA&lt;/option&gt;
                      &lt;option value="SWO-CAN"&gt;SoftwareONE CAN&lt;/option&gt;
                      &lt;option value="SWO-CHL"&gt;SoftwareONE CHL&lt;/option&gt;
                      &lt;option value="SWO-COL"&gt;SoftwareONE COL&lt;/option&gt;
                      &lt;option value="SWO-CRI"&gt;SoftwareONE CRI&lt;/option&gt;
                      &lt;option value="SWO-DOM"&gt;SoftwareONE DOM&lt;/option&gt;
                      &lt;option value="SWO-ECU"&gt;SoftwareONE ECU&lt;/option&gt;
                      &lt;option value="SWO-EMEA"&gt;SoftwareONE EMEA&lt;/option&gt;
                      &lt;option value="SWO-GTM"&gt;SoftwareONE GTM&lt;/option&gt;
                      &lt;option value="SWO-HKG"&gt;SoftwareONE HKG&lt;/option&gt;
                      &lt;option value="SWO-HND"&gt;SoftwareONE HND&lt;/option&gt;
                      &lt;option value="SWO-IDN"&gt;SoftwareONE IDN&lt;/option&gt;
                      &lt;option value="SWO-JAM"&gt;SoftwareONE JAM&lt;/option&gt;
                      &lt;option value="SWO-JPN"&gt;SoftwareONE JPN&lt;/option&gt;
                      
                      &lt;/select&gt;
                      &lt;/span&gt;
                  &lt;/div&gt;
              &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p><a href="https://i.stack.imgur.com/Jj7Zk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jj7Zk.jpg" alt="enter image description here"></a></p>
  
  <p>1) I was able to click on the  tag using, but not able to select the item: </p>
  
  <pre><code>driver.FindElement(By.CssSelector("span[aria-owns='cboAccountSettings_listbox']")).Click();
  </code></pre>
  
  <p>2) I used this code also, but not able to find the specific element:</p>
  
  <pre><code>var LSPAccount = WebBrowser.FindElement(By.CssSelector("span[aria-owns='cboAccountSettings_listbox']"));   
  Thread.Sleep(1000);
  var selectElement = new SelectElement(LSPAccount);
  Thread.Sleep(1000);
  selectElement.SelectByValue("SWO-ARG");
  </code></pre>
  
  <p>3) I also tried this , but no success: </p>
  
  <pre><code>var xpath = "//span[contains(@class,'k-widget k-dropdown k-header')][contains(@id,'cboAccountSettings')][contains(text(),'SoftwareONE ARG')]";
  var admi = WebBrowser.FindElement(By.XPath(xpath));
  Thread.Sleep(1000);
  admi.Click();
  </code></pre>