webdriver 如何处理时间控件:
1、使用比较普遍,也很通俗的方法
先切换到时间控件的frame,再在frame中实现所要点击时间的操作
2、使用js,实现把时间标签中的value属性赋值,这个值就是你想要选择的时间,注意时间格式;若改时间标签为只读,需要把只读限制去掉
以下为代码:
String js="document.getElementById('dateTimeId').removeAttribute('readOnly');document.getElementById('dateTimeId').setAttribute('value','2012-10-25');";
((JavascriptExecutor) driver).executeScript(js);
1、使用比较普遍,也很通俗的方法
先切换到时间控件的frame,再在frame中实现所要点击时间的操作
2、使用js,实现把时间标签中的value属性赋值,这个值就是你想要选择的时间,注意时间格式;若改时间标签为只读,需要把只读限制去掉
以下为代码:
String js="document.getElementById('dateTimeId').removeAttribute('readOnly');document.getElementById('dateTimeId').setAttribute('value','2012-10-25');";
((JavascriptExecutor) driver).executeScript(js);
本文介绍了使用 WebDriver 处理时间控件的两种方法:通过切换 frame 进行点击操作及利用 JavaScript 修改时间标签的值属性。针对不同场景提供了具体代码示例。
1691

被折叠的 条评论
为什么被折叠?



