【问题标题】:unable to set date in firefox 57 using selenium version 3.4无法使用 selenium 3.4 版在 Firefox 57 中设置日期
【发布时间】:2017-12-26 11:57:00
【问题描述】:

date Field图片

无法使用sendKeys 函数设置超过指定日期字段的日期信息

已尝试使用 java 脚本但无法设置值。

更新 HTML

driver.findelementBy("//label[text()='Past Specified']/../div[@class='radioHide']//input[1]").sendkeys("01082016");

(JavascriptExecutor)driver.executeScript(arguments[0].setAttribute('value', '"+sText+"');",element))

请帮忙

【问题讨论】:

  • 请您的代码试用和相关的HTML
  • 用 HTML 和试验更新
  • 请阅读为什么是screenshot of code or HTML is a bad idea。考虑使用基于格式化文本的 HTML 和代码试验来更新问题。
  • "xpath" 的值与driver.findelementBy("xpath").sendkeys("01082016"); 一样
  • @Debanjan 使用 Xpath 更新

标签: javascript java selenium firefox selenium-webdriver


【解决方案1】:

您的日期格式不正确。试试下面的,

driver.findelementBy("//label[text()='Past Specified']/../div[@class='radioHide']//input[1]").sendkeys("01/08/2016");

或使用 javascript

String sText="01/08/2016";
(JavascriptExecutor)driver.executeScript(arguments[0].setAttribute('value', '"+sText+"');",element))

【讨论】:

  • 两种情况都试过了。它没有用。此外,Calender 不是基于 html 来检查元素
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-04
相关资源
最近更新 更多