pythonseleniumdatepickeronclickonpaste

onkeypress="return false;" onpaste="return false;"


I have a Website that does not allow me to paste in the search dates. It has set """ onkeypress="return false;" onpaste="return false;" """ on the date field.

I am looking for workarounds to implement date picker in python + selenium rather than Java. The Webpage is http://www.bseindia.com/corporates/corporate_act.aspx?expandable=0

The From Date field is coded as this

<td height="30" width="73" bgcolor="#ffffff" valign="middle">
  <b>From Date</b>
</td>
<td width="300" height="30" bgcolor="#ffffff">
  <input name="ctl00$ContentPlaceHolder1$txtDate" type="text" id="ctl00_ContentPlaceHolder1_txtDate" class="textbox2" onkeyup="clearText(event,'ctl00_ContentPlaceHolder1_txtDate')" onkeypress="return false;" onpaste="return false;" onclick="showCalendarControl('ctl00_ContentPlaceHolder1_txtDate', 'Div3',false);" style="width:100px;" />
  <img src="../include/images/calender01.gif" id="img2" style="cursor: hand" onclick="showCalendarControl('ctl00_ContentPlaceHolder1_txtDate', 'Div3',false)"
                                    align="middle" alt="Calendar" />
  <div id="Div3">
  </div>
</td>

Any idea how to automate the showCalendarControl and pick a date?


Solution

  • Got the Solution.. Was quite simple actually...

    driver.find_element_by_id("ctl00_ContentPlaceHolder1_txtDate").click() a = driver.execute_script("return setCalendarControlDate( 2014,12,1);") driver.find_element_by_id("ctl00_ContentPlaceHolder1_txtTodate").click() a = driver.execute_script("return setCalendarControlDate( 2015,1,11);") driver.find_element_by_id("ctl00_ContentPlaceHolder1_btnSubmit").click() elem = driver.find_element_by_id("ctl00_ContentPlaceHolder1_lnkDownload")

    Thanks