all,
我们正在尝试自动化日期选择过程参考单击此处!。请参阅出生日期和约会日期。我们选择日期的方式不同。我无法对选择两个字段的日期有任何想法。你能帮我吗?
我已经尽力了,它正在使用以下代码,但日期字段
Python版本:2.7硒3.8.0铬:48x
import selenium
import sys
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.chrome.options import Options
#profile = webdriver.FirefoxProfile()
#profile.accept_untrusted_certs = True
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = Options()
chrome_options.add_argument("--disable-extensions")
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get('https://reentryvisa.inis.gov.ie/website/INISOA/IOA.nsf/AppointmentSelection?OpenForm');
wait = WebDriverWait(driver, 10)
driver.find_element_by_id('btCom').click()
username = driver.find_element_by_id('GivenName')
username.send_keys("First name here ")
username = driver.find_element_by_id('Surname')
username.send_keys("Surname here")
username = driver.find_element_by_id('DOB')
username.click()
ActionChains(driver).move_to_element(username).click().send_keys('01/01/2011').perform()
username = driver.find_element_by_id('Appdate')
username.send_keys("12345")
我尝试查看ID名称等的HTML,但我发现了任何特定于年或一个月的东西。我所得到的只是代码
<script src="/website/INISOA/IOA.nsf/bootstrap-datepicker.js"></script>
<link href="/website/INISOA/IOA.nsf/datepicker3.css" rel="stylesheet">
<div class="form-group">
<label class="control-label col-sm-3 col-md-3 col-lg-2" for="DOB">* Date of Birth:</label>
<div class="col-sm-3 col-md-3 col-lg-3">
<div class="input-group date dobdate">
<input name="DOB" value="" id="DOB" class="form-control readonlywhite" placeholder="Date of birth" readonly>
<span class="input-group-addon"><i class="glyphicon glyphicon-calendar"></i></span>
</div>
</div>
</div>
请帮助我展示以选择两个领域的日期(出生日期和约会日期)
出生日期:
dob = driver.find_element_by_id('DOB')
driver.execute_script("arguments[0].value = arguments[1]", dob, '01/01/2011')
预约日期:
appdate = driver.find_element_by_id('Appdate')
driver.execute_script("arguments[0].value = arguments[1]", appdate, '12/12/2017')
html的日期/月/年弹出窗口不在'dob输入'之下。您可以使用以下选择器
选择弹出窗口datePopup = driver.find_element_by_class('datepicker-days')
monthPopup = driver.find_element_by_class('datepicker-month')
yearPopup = driver.find_element_by_class('datepicker-years')