title: How to select an <option> within a <select> tag using Selenium in Python 3?
body: <p>new to Python here so thanks in advance and sorry if I say something really basically obvious.</p>
  
  <p>The option I want to click on is quite nested (don't know if it makes a difference, it might since I'm pretty ignorant in the subject). The nesting goes:</p>
  
  <pre><code>&lt;frameset &lt;frame &lt;html &lt;body &lt;form &lt;table &lt;tbody &lt;tr &lt;td &lt;p &lt;select &lt;option
  </code></pre>
  
  <p>The select has name='base' and size=15, thats it.
  The option has value='B101' and Text='Cam'</p>
  
  <p>Here is what I have:</p>
  
  <pre class="lang-py prettyprint-override"><code>table = driver.find_element_by_name('base')
           for option in table.find_elements_by_tag_name('option'):
               if option.text == 'Cam':
                   option.click()
                   break`
  </code></pre>
  
  <p>But is breaks at the first line, with this error</p>
  
  <pre><code>selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="base"]"}
  </code></pre>
  
  <p>Also tried using the xpath but i get this: <code>/html/body/form/table/tbody/tr[2]/td[2]/input</code>, (instead of what I am used to something like <code>//*[@id=...</code>) and it doesn't find it either. Not by class 'select'.</p>
  
  <p>Also tried going directly to the option by xpath, name, class, nothing works.
  I just cannot seem to click the option. Don't know if it makes a difference here but I'm on a mac and using ChromeDriverManager.
  After clicking the option I have to click on 'Select' to go to the next page.</p>
  
  <p>EDIT:
  Thanks Shreyas! Excuse my ignorance, I did that, and it does not bring an error, but nor do I see the option selected. After clicking on the option I would have to click on a 'Select' button (tag 'input'), which I also cannot find with Selenium. Here is the HTML in case it helps:</p>
  
  <pre><code>&lt;frameset rows="40,*,25" frameborder="0" framespacing="0"&gt;
      &lt;frame name="Results" src="/documents/bases.jsp" marginwidth="3" marginheight="3"&gt;
          #document
              &lt;html&gt;&lt;head&gt;&lt;title&gt;Base&lt;/title&gt;
  &lt;meta http-equiv="expires" content="Wed, 26 Feb 1997"&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
  &lt;/head&gt;
  &lt;body bgcolor="#FFFFFF" marginwidth="3" marginheight="3"&gt;
  &lt;form method="POST" action="/documents/bases.jsp"&gt;
  &lt;input type="hidden" name="tdb" value="B"&gt;
  &lt;table align="center" border="0"&gt;
      &lt;tbody&gt;&lt;tr&gt;
          &lt;td valign="top"&gt;&lt;img src="/images/bases.jpg" width="30" height="28"&gt;&lt;/td&gt;
          &lt;td&gt;
              &lt;p align="center"&gt;&lt;font color="#804040" size="4" face="Verdana"&gt;&lt;b&gt;
              Available Base
              &lt;/b&gt;&lt;/font&gt;&lt;/p&gt;
              &lt;p align="center"&gt;
              &lt;select name="base" size="15" multiple=""&gt;
  &lt;option value="B096"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B101"&gt;This_option&lt;/option&gt;
  &lt;option value="B109"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B110"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B151"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B158"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B170"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B219"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B221"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B222"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B223"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B261"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B300"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B351"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B352"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B502"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B511"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B649"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B650"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B660"&gt;Not_this_option&lt;/option&gt;
  &lt;option value="B704"&gt;Not_this_option&lt;/option&gt;
              &lt;/select&gt;
              &lt;/p&gt;
          &lt;/td&gt;
          &lt;!--
          &lt;td align='center' valign='top'&gt;
              &lt;table border='1'&gt;
                  &lt;tr&gt;
                      &lt;td align='center'&gt;
                          &lt;font size='2'&gt;&lt;b&gt;What kind&lt;br&gt;
                          Of base do you wanna see?&lt;/b&gt;&lt;/font&gt;&lt;p&gt;
                          &lt;a href='bases.jsp?tdb=B' target='Results'&gt;Kind1/a&gt;&lt;br&gt;
                          &lt;a href='bases.jsp?tdb=F' target='Results'&gt;Kind2&lt;/a&gt;&lt;/p&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/td&gt;
          --&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
          &lt;td align="center"&gt;
              &lt;input type="submit" name="Select" value="Select"&gt;
          &lt;/td&gt;
          &lt;td&gt;&amp;nbsp;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/tbody&gt;&lt;/table&gt;
  &lt;/form&gt;
  &lt;/body&gt;&lt;/html&gt;
  </code></pre>