selenium webdriver自动化对日期控件的处理
用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')。。。。。 用这种方法比较简便,不过有一个缺点,因为是直接给日期输入框赋值,所以无法验证日期控件是否正常。 来源: https://www.cnblogs.com/liu-ke/p/4200736.html