Dropdown menus in python / selenium
<p>Trying to autofill a form using python and selenium. Dropdown menu html is:</p>

<pre><code>&lt;select id="typeOfTeacher" class="chosen-select-no-single ng-untouched ng-dirty ng-valid-parse ng-valid ng-valid-required" required="" ng-class="{ 'has-error' : positionDetailForm.typeOfTeacher.$invalid &amp;&amp; !positionDetailForm.typeOfTeacher.$pristine }" ng-change="vm.setRequired()" tabindex="-1" ng-model="vm.data.typeOfTeacher" name="typeOfTeacher" data-placeholder="Select" style="display: none;"&gt;
&lt;option value="" disabled="" selected=""&gt;Select&lt;/option&gt;
&lt;option class="ng-binding ng-scope" value="1" ng-repeat="teacherType in vm.teacherTypes"&gt;No position at the moment&lt;/option&gt;
&lt;option class="ng-binding ng-scope" value="2" ng-repeat="teacherType in vm.teacherTypes"&gt;Supply&lt;/option&gt;
&lt;option class="ng-binding ng-scope" value="3" ng-repeat="teacherType in vm.teacherTypes"&gt;Permanent&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>Python code is:</p>

<pre><code>elem = Select(browser.find_element_by_id('typeOfTeacher'))
elem.select_by_value("1")
</code></pre>

<p>Error is "element is not currently visible and may not be interacted with".</p>

<p>It looks like timing issue. You should try using <a href="http://selenium-python.readthedocs.io/waits.html#waits" rel="nofollow">Waits</a>. </p>

<p>I would suggest you, use <code>WebDriverWait</code> to wait until dropdown visible before interaction as below :-</p>

<pre><code>from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

element = WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.ID, "typeOfTeacher")))

select = Select(element)
select.select_by_value("1")
</code></pre>

python selenium selenium-webdriver