用JS去掉日期输入框的readOnly属性。

代码如下:

-------------------------------------------------------------------------------------

String js="document.getElementById('dateTimeId').removeAttribute('readOnly');document.getElementById('dateTimeId').setAttribute('value','2012-10-25');";

((JavascriptExecutor) driver).executeScript(js);

--------------------------------------------------------------------------------------

getElementById('dateTimeId')

也可以用其他方式获取元素,如:getElementByName('dateTimeIdName')。。。。。

用这种方法比较简便,不过有一个缺点,因为是直接给日期输入框赋值,所以无法验证日期控件是否正常。

相关文章:

  • 2021-07-18
  • 2022-12-23
  • 2021-07-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-08-15
猜你喜欢
  • 2021-11-02
  • 2022-12-23
  • 2021-06-29
  • 2021-07-27
  • 2021-10-19
  • 2022-12-23
相关资源
相似解决方案