自动化测试如何处理日期控件
2017-10-11 本文已影响73人
Leo_0626
1、手动定位时间控件中的日期,手动选择,其中还要切换到时间控件框架,然后再切换回来,想想就麻烦,本人不太推荐
2、一般时间控件是有readonely属性,这里我们可以采用执行js脚本,去掉input标签中的readonly属性,这个时候就可以直接输入时间,send_keys()。
![](https://img.haomeiwen.com/i5397377/0e46c62a4b07cfa3.png)
js = document.getElementById().removeAttribute("readonly")
driver.execute_script(js)
3、如果时间控件readonly属性隐藏,可以直接给value赋值
![](http://upload-images.jianshu.io/upload_images/5397377-0efce166e32662e2.png)
js = document.getElementById().value="2017-02"
driver.execute_script(js)