【问题标题】:Python - Selenium - Two equal website imput boxes, one works with send_keys(), the other doesntPython - Selenium - 两个相等的网站输入框,一个使用 sendkeys(),另一个不使用
【发布时间】:2018-11-09 22:49:57
【问题描述】:

我正在使用 Python 3.7 和 Selenium,尝试使用 send_keys() 将日期和时间输入到网站中两个明显相同的文本输入框中。

时间输入框工作正常,send_keys('00:00:00') 根据需要写入时间。

无论我尝试使用什么格式发送字符串,日期输入框都没有反应。我试过在写之前添加一个.click()、.clear()、Keys.HOME,无济于事。

我不知道有什么区别。

startTimeBox = browser.find_element_by_name('TimeStart')
startTimeBox.get_attribute('outerHTML')
Out[187]: '<input name="TimeStart" id="TimeStart" title="Please enter start time" size="10" maxlength="12" value="00:00:00" type="time">'

startDateBox = browser.find_element_by_name('DateStart')
startDateBox.get_attribute('outerHTML')
Out[185]: '<input name="DateStart" id="DateStart" title="Please enter start date" size="10" maxlength="11" value="09/11/2018" style="" type="date">'

好吧,并排看这个,我注意到日期框中的“样式”部分。我想这可能会影响它。

【问题讨论】:

标签: python selenium textinput


【解决方案1】:

正如 cmets 中提到的 JacobIRR,Firefox 驱动程序可能存在问题,而不是使用 Chrome 驱动程序或在发送密钥之前单击该字段。

解决方案是在发送密钥之前尝试使用click()

【讨论】:

    猜你喜欢
    • 2018-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-12
    • 1970-01-01
    • 2019-01-30
    • 2021-09-03
    相关资源
    最近更新 更多