Selecting a combobox option with a <div> tag using Selenium and Python
<p>I have been trying to automate some really boring stuff (because of how tedious I have been making mistakes and I want to reduce them as close as zero as I can), in essence I got assets that have to be entered into our system one by one through a horrible process. This is my problem right now:</p>

<p>My objective is to select the option 'CELL PHONES' on the drop down list (ctl00_CPH1_cmbClasses_DropDown). Also for security reasons and the fact that it is a protected Corporate Page (I already handled login and navigation till this point) I can only show snippets of the code as to not compromise it. </p>

<p>EDIT 1 (Modified this to add more of the HTML code)</p>

<pre><code>&lt;td class="rcbInputCell rcbInputCellLeft" style="width:100%;"&gt;&lt;input name="ctl00$CPH1$cmbClasses" type="text" class="rcbInput radPreventDecorate" id="ctl00_CPH1_cmbClasses_Input" value="" /&gt;&lt;/td&gt;&lt;td class="rcbArrowCell rcbArrowCellRight"&gt;&lt;a id="ctl00_CPH1_cmbClasses_Arrow" style="overflow: hidden;display: block;position: relative;outline: none;"&gt;select&lt;/a&gt;&lt;/td&gt;
                &lt;/tr&gt;
            &lt;/table&gt;&lt;div class="rcbSlide" style="z-index:6000;"&gt;&lt;div id="ctl00_CPH1_cmbClasses_DropDown" class="RadComboBoxDropDown RadComboBoxDropDown_WebBlue " style="display:none;width:140px;"&gt;&lt;div class="rcbScroll rcbWidth" style="width:100%;"&gt;&lt;ul class="rcbList" style="list-style:none;margin:0;padding:0;zoom:1;"&gt;&lt;li class="rcbItem"&gt;&lt;/li&gt;&lt;li class="rcbItem"&gt;CELL PHONES&lt;/li&gt;&lt;li class="rcbItem"&gt;CELLULAR PHONE SCRAP (WITHOUT BATTERIES)&lt;/li&gt;&lt;li class="rcbItem"&gt;COMPUTER - DESKTOP&lt;/li&gt;&lt;li class="rcbItem"&gt;COMPUTER -TOWER&lt;/li&gt;&lt;li class="rcbItem"&gt;COMPUTERS&lt;/li&gt;&lt;li class="rcbItem"&gt;COMPUTERS - SFF&lt;/li&gt;&lt;li class="rcbItem"&gt;COPPER BEARING - LOW GRADE&lt;/li&gt;&lt;li class="rcbItem"&gt;Desktop&lt;/li&gt;&lt;li class="rcbItem"&gt;FLOPPY DISK DRIVES&lt;/li&gt;&lt;li class="rcbItem"&gt;GARBAGE - NON HAZARDOUS&lt;/li&gt;&lt;li class="rcbItem"&gt;LAPTOPS&lt;/li&gt;&lt;li class="rcbItem"&gt;LCD Monitor&lt;/li&gt;&lt;li class="rcbItem"&gt;MISC. ELECTRONICS&lt;/li&gt;&lt;li class="rcbItem"&gt;MISCELLANEOUS&lt;/li&gt;&lt;li class="rcbItem"&gt;MODEMS&lt;/li&gt;&lt;li class="rcbItem"&gt;NETWORK EQUIPMENT&lt;/li&gt;&lt;li class="rcbItem"&gt;OCC&lt;/li&gt;&lt;li class="rcbItem"&gt;PHONES - DIGITAL&lt;/li&gt;&lt;li class="rcbItem"&gt;PRINTERS&lt;/li&gt;&lt;li class="rcbItem"&gt;SERVERS&lt;/li&gt;&lt;li class="rcbItem"&gt;SERVERS - TOWER&lt;/li&gt;&lt;li class="rcbItem"&gt;Telecom Equipment&lt;/li&gt;&lt;li class="rcbItem"&gt;Telephone&lt;/li&gt;&lt;li class="rcbItem"&gt;Telephone Accessory&lt;/li&gt;&lt;li class="rcbItem"&gt;TEST EQUIPMENT&lt;/li&gt;&lt;li class="rcbItem"&gt;WIRE &amp;amp; CABLE - MISC. &lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;input id="ctl00_CPH1_cmbClasses_ClientState" name="ctl00_CPH1_cmbClasses_ClientState" type="hidden" /&gt;
        &lt;/div&gt;
</code></pre>

<p>This is the combobox code from the page (corporate web form), I am trying to select it but my current codes and attempts (some from other post here in Stack Overflow) have failed so far, this is what I have attempted so far:</p>

<pre><code>def fast_multiselect(driver, element_id, labels):
select = browser.find_element_by_id('ctl00_CPH1_cmbClasses_DropDown')
for option in select.find_element_by_name('CELL PHONE'):
    if option.text in labels:
        option.click()
</code></pre>

<p>This was my first attempt (several iterations of the same code) and the result was Python not listing any errors but not selecting the option I wanted so following advice from here I went for this:</p>

<pre><code>selectDropDownList = browser.find_element_by_id("ctl00_CPH1_cmbClasses_DropDown &gt; option[value='CELL PHONE']").click()
</code></pre>

<p>And this was the result:</p>

<blockquote>
  <p>Traceback (most recent call last):
    File "C:\Users\AMSUser\AppData\Local\Programs\Python\Python35-32\Scripts\Add Asset.py", line 77, in 
      selectDropDownList = browser.find_element_by_id("ctl00_CPH1_cmbClasses_DropDown > option[value='CELL PHONE']").click()
    File "C:\Users\AMSUser\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 269, in find_element_by_id
      return self.find_element(by=By.ID, value=id_)
    File "C:\Users\AMSUser\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 752, in find_element
      'value': value})['value']
    File "C:\Users\AMSUser\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 236, in execute
      self.error_handler.check_response(response)
    File "C:\Users\AMSUser\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 192, in check_response
      raise exception_class(message, screen, stacktrace)
  selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"ctl00_CPH1_cmbClasses_DropDown > option[value='CELL PHONE']"}
    (Session info: chrome=52.0.2743.116)
    (Driver info: chromedriver=2.23.409699 (49b0fa931cda1caad0ae15b7d1b68004acd05129),platform=Windows NT 10.0.10586 x86_64)</p>
</blockquote>

<p>I continued marching forward and this was my last attempt:</p>

<pre><code>Select(browser.find_element_by_id('ctl00_CPH1_cmbClasses_DropDown')).select_by_value('CELL PHONES')
</code></pre>

<p>And the result is:</p>

<blockquote>
  <p>Traceback (most recent call last):
    File "C:\Users\AMSUser\AppData\Local\Programs\Python\Python35-32\Scripts\Add Asset.py", line 78, in 
      Select(browser.find_element_by_id('ctl00_CPH1_cmbClasses_DropDown')).select_by_value('CELL PHONES')
    File "C:\Users\AMSUser\AppData\Local\Programs\Python\Python35-32\lib\site-packages\selenium\webdriver\support\select.py", line 39, in <strong>init</strong>
      webelement.tag_name)
  selenium.common.exceptions.UnexpectedTagNameException: Message: Select only works on  elements, not on </p>
</blockquote>

<p>Your problem is that this element is not <code>Select</code> but <code>&lt;div&gt;</code>, so you cannot use Selenium's Select class.</p>

<p>I don't see page which you are working at, but i suppose that <code>&lt;div&gt;</code> with id = ctl00_CPH1_cmbClasses_DropDown is element which you have to click on to show dropdown list?</p>

<p>If it is, then you have to find that element by id, click on it, then find another element <code>&lt;li&gt;</code> that contains text 'CELL PHONE' or whatever you want - for example using xpath.</p>

<p><a href="http://docs.seleniumhq.org/docs/03_webdriver.jsp#locating-ui-elements-webelements" rel="nofollow">this WebDriver docs page will help you</a></p>

python selenium