Python Selenium Webpage Scraping Selecting Drop Down and entering text in html form
<p>I have a problem scraping data from the following site: <a href="https://arcc.sdcounty.ca.gov/Pages/Assessors-Roll-Tax.aspx" rel="nofollow">https://arcc.sdcounty.ca.gov/Pages/Assessors-Roll-Tax.aspx</a>. </p>

<p>I have to do these steps in order:</p>

<ol>
<li><p>Select a drop down option "Street Address'</p></li>
<li><p>Enter a street address into a text field (ie 43 Hadar Dr)</p></li>
<li><p>Click the 'Submit' button. </p></li>
</ol>

<p>After clicking submit, I should be directed to a page that has the APN number for a given address.</p>

<p><strong>The problem:</strong>
I am able to do the above steps. However, when I select a drop down option and input address in the textbox, it fails as the textbox input address for some reason is cleared before clicking 'submit' ONLY when I have selected a drop down option. </p>

<p>I have tried using Selenium's Expected Conditions to trigger the input in the text box after a drop down option has been selected, but did nothing. I am looking for any help on identifying the why there is this problem as well as any advice on solutions. </p>

<p>Thanks.Much appreciated.</p>

<p><strong>My code:</strong></p>

<pre><code>    driver = webdriver.Chrome()
    driver.get('https://arcc.sdcounty.ca.gov/Pages/Assessors-Roll-Tax.aspx')
    #Selects drop down option ('Street Address')
    mySelect =        Select(driver.find_element_by_id("ctl00_ctl43_g_d30f33ca_a5a7_4f69_bb21_cd4abc25  ea12_ctl00_ddlSearch"))
    my=mySelect.select_by_value('0')  
    wait = WebDriverWait(driver,300)
    #Enter address in text box to left of drop down
   driver.find_element_by_id("ctl00_ctl43_g_d30f33ca_a5a7_4f69_bb21_cd4abc25ea12_ct    l00_txtSearch").send_keys("11493 hadar dr")
    #Click 'Submit' button to return API numbers associated with address
    driver.find_element_by_id("ctl00_ctl43_g_d30f33ca_a5a7_4f69_bb21_cd4abc25ea12_ctl00_btnSearch").click()
    driver.quit()
</code></pre>

<p>Just changed a few things in your code to make it work.</p>

<pre><code>mySelect = Select(driver.find_element_by_id("ctl00_ctl43_g_d30f33ca_a5a7_4f69_bb21_cd4abc25  ea12_ctl00_ddlSearch"))
</code></pre>

<p>To find_element_by_name(...):</p>

<pre><code>mySelect = Select(driver.find_element_by_name("ctl00$ctl43$g_d30f33ca_a5a7_4f69_bb21_cd4abc25ea12$ctl00$ddlSearch"))
</code></pre>

<p>And</p>

<pre><code>my=mySelect.select_by_value('0')
</code></pre>

<p>To select_by_visible_text('...'):</p>

<pre><code>my = mySelect.select_by_visible_text("Street Address")
</code></pre>

<p>And</p>

<pre><code>driver.find_element_by_id("ctl00_ctl43_g_d30f33ca_a5a7_4f69_bb21_cd4abc25ea12_ct l00_txtSearch").send_keys("11493 hadar dr")
</code></pre>

<p>To find_element_by_xpath(...), since I usually get better results when finding elements by xpath.</p>

<pre><code>driver.find_element_by_xpath('//*[@id="ctl00_ctl43_g_d30f33ca_a5a7_4f69_bb21_cd4abc25ea12_ctl00_txtSearch"]').send_keys("11493 hadar dr")
</code></pre>

<p>This is how it all looks like:</p>

<pre><code>from selenium.webdriver.support.ui import WebDriverWait
from selenium import webdriver
from selenium.webdriver.support.ui import Select

driver = webdriver.Chrome()
driver.get('https://arcc.sdcounty.ca.gov/Pages/Assessors-Roll-Tax.aspx')

#Selects drop down option ('Street Address')
mySelect = Select(driver.find_element_by_name("ctl00$ctl43$g_d30f33ca_a5a7_4f69_bb21_cd4abc25ea12$ctl00$ddlSearch"))
my = mySelect.select_by_visible_text("Street Address")

wait = WebDriverWait(driver,300)

#Enter address in text box to left of drop down
driver.find_element_by_xpath('//*[@id="ctl00_ctl43_g_d30f33ca_a5a7_4f69_bb21_cd4abc25ea12_ctl00_txtSearch"]').send_keys("11493 hadar dr")

#Click 'Submit' button to return API numbers associated with address
driver.find_element_by_id("ctl00_ctl43_g_d30f33ca_a5a7_4f69_bb21_cd4abc25ea12_ctl00_btnSearch").click()

driver.quit()
</code></pre>

python html selenium selenium-webdriver