0

我的网站不允许我粘贴搜索日期。它在日期字段上设置了 """ onkeypress="return false;" onpaste="return false;" """。

我正在寻找解决方法来在 python + selenium 而不是 Java 中实现日期选择器。该网页是http://www.bseindia.com/corporates/corporate_act.aspx?expandable=0

从日期字段编码如下

<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>

知道如何自动化 showCalendarControl 并选择日期吗?

4

1 回答 1

-1

得到了解决方案..实际上很简单......

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")

谢谢

于 2015-01-11T11:36:13.487 回答