Using selenium on calendar date picker
<p>I am trying to pick a date (01/01/2011) from a calendar on this page. <a href="https://cotthosting.com/NYRocklandExternal/LandRecords/protected/SrchQuickName.aspx" rel="nofollow">https://cotthosting.com/NYRocklandExternal/LandRecords/protected/SrchQuickName.aspx</a></p>

<p>The calendar is on the part of the form that says <code>Date: FROM</code>. When I click it, a calendar pops up for you to pick dates. However, the field also allows you type in a date. Given the complexity of calendars, I have chosen to use <code>send_keys()</code> but it is not working.</p>

<p>I have identified the empty field date field by its ID but for some reason it does not fill the form. when I try:</p>

<pre><code>driver.find_element_by_id('ctl00_cphMain_SrchDates1_txtFiledFrom').send_keys("01012011")
</code></pre>

<p>Any ideas on how I can maneuver it differently? I'm using Python 2.7 with Selenium and ChromeDriver</p>

<p>To get this to work, add one extra step of clicking the element before sending the keys:</p>

<pre><code>datefield = driver.find_element_by_id('ctl00_cphMain_SrchDates1_txtFiledFrom')
datefield.click()
datefield.send_keys("01012011")
</code></pre>

<h1>Update:</h1>

<p>It looks like you might have to use <a href="http://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.common.action_chains" rel="nofollow"><code>ActionChains</code></a> after all in your case, which will allow you to chain a series of actions together, and then perform them one after the other:</p>

<pre><code>from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains

driver = webdriver.Chrome()

driver.get("https://cotthosting.com/NYRocklandExternal/User/Login.aspx")
driver.find_element_by_id('ctl00_cphMain_blkLogin_btnGuestLogin').click()

driver.find_element_by_id('ctl00_cphMain_SrchNames1_txtFirmSurName').send_keys("Adam")

datefield = driver.find_element_by_id('ctl00_cphMain_SrchDates1_txtFiledFrom')

ActionChains(driver).move_to_element(datefield).click().send_keys('01012011').perform()
search_btn = driver.find_element_by_id('ctl00_cphMain_btnSearchAll')
ActionChains(driver).move_to_element(search_btn).click().click().perform()
</code></pre>

<p>I am not sure why two <code>click()</code> calls were necessary in this case, but it seems that they were. I tried a few other things including <code>double_click()</code>, but this was the only thing that worked for me to get the datefield unfocused and then click the search button.</p>

python selenium datepicker