我有一个网站,不允许我粘贴搜索日期。它在日期字段上设置了“”“onkeypress =”return false;“onpaste =”return false;“”“”。
我正在寻找在python + selenium而不是Java中实现日期选择器的变通方法。网页为http://www.bseindia.com/corporates/corporate_act.aspx?expandable=0
From Date字段编码为
<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并选择日期吗?
答案 0 :(得分:-1)
得到解决方案..实际上很简单......
driver.find_element_by_id(&#34; ctl00_ContentPlaceHolder1_txtDate&#34)。单击() a = driver.execute_script(&#34; return setCalendarControlDate( 2014,12,1);&#34) driver.find_element_by_id(&#34; ctl00_ContentPlaceHolder1_txtTodate&#34)。单击() a = driver.execute_script(&#34; return setCalendarControlDate( 2015,1,11);&#34) driver.find_element_by_id(&#34; ctl00_ContentPlaceHolder1_btnSubmit&#34)。单击() elem = driver.find_element_by_id(&#34; ctl00_ContentPlaceHolder1_lnkDownload&#34)
由于