【发布时间】:2018-05-21 12:35:28
【问题描述】:
全部,
我们正在尝试自动化日期选择过程供参考Click here! .请参阅出生日期和约会日期字段。我们选择日期的方式不同。我无法为这两个字段选择日期。你能帮帮我吗?
我已经尽力了,它可以使用以下代码,日期字段除外
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")
我尝试查看 html 的 id 名称等,但我找不到任何特定于年份或月份的内容。我得到的只是下面的代码
<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>
请帮我在两个字段中选择日期(出生日期和约会日期)
【问题讨论】:
标签: python python-2.7 date selenium