Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 调用onclick datepicker函数python selenium_Javascript_Python_Selenium_Selenium Webdriver_Web Scraping - Fatal编程技术网

Javascript 调用onclick datepicker函数python selenium

Javascript 调用onclick datepicker函数python selenium,javascript,python,selenium,selenium-webdriver,web-scraping,Javascript,Python,Selenium,Selenium Webdriver,Web Scraping,我是selenium的新手,我正在尝试将值传递到表单中。虽然我能够在普通文本框中传递值,但onclick-datepicker函数无法成功。这是代码 import urllib from selenium import webdriver from selenium.webdriver.support.ui import Select from selenium.webdriver.common.keys import Keys driver = webdriver.PhantomJS(exe

我是selenium的新手,我正在尝试将值传递到表单中。虽然我能够在普通文本框中传递值,但onclick-datepicker函数无法成功。这是代码

import urllib
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common.keys import Keys

driver = webdriver.PhantomJS(executable_path="C://Users//phantomjs//bin//phantomjs.exe")
driver.get('https://enquiry.icegate.gov.in/enquiryatices/sbTrack')
select = Select(driver.find_element_by_name('sbTrack_location'))
select.select_by_value("MUNDRA SEA (INMUN1)")
sb_no = driver.find_element_by_name("SB_NO")
sb_no.send_keys(7353156)
sb_dt = driver.find_element_by_name("SB_DT")
sb_dt.send_keys("2017/07/14")

driver.save_screenshot("test1_scr.png")
我无法从发送键到带有
readonly input
属性的标记


在指定日期选择今天的日期,例如2018/03/26您可以使用以下代码行:

driver.find_element_by_xpath("//img[@src='/enquiryatices/image/Dateicon.gif']").click()
driver.find_element_by_xpath("//table[@class='dpTable']//td/div[@class='dpDayHighlight']").click()

更新 根据您的评论,要传递自定义日期,例如2017/07/14,您必须删除属性readonly=“readonly”,然后以文本形式发送日期,如下所示:

sb_dt = driver.find_element_by_xpath("//input[@id='sbDATE']")
driver.execute_script("arguments[0].removeAttribute('readonly')", sb_dt);
sb_dt.send_keys("2017/07/14")

我如何通过我自己的日期说“2017/07/14”@DebanjanBCheckout我的答案更新,让我知道状态。太好了!它正在工作,还有一个疑问是我如何提交表单并获得结果页面代码
sb_dt = driver.find_element_by_xpath("//input[@id='sbDATE']")
driver.execute_script("arguments[0].removeAttribute('readonly')", sb_dt);
sb_dt.send_keys("2017/07/14")