1当遇到html中遇到日历的情况时input标签中含有readonly属性时 我们使用selenium webdriver去定位元素send_keys无效我们需要通过执行js去消除改属性。
普通的js语句为
js=‘document.getElementById("ID"). removeAttribute("readonly")’
如果没有id怎么办?那就按照元素名称查找
js=‘document.getElementsByName("NAME"). removeAttribute("readonly")’
如果name也没有怎么办按照元素名字
js=‘document.getElementsByTagName("p"). removeAttribute("readonly")’
如果上面也解决不了怎么办?那就执行 jquery方法
js='$("input").removeAttr("readonly")' 执行该语句 想自己定义就去查jq
2隐藏元素如何赋值? 这里还是通过js来操作 这里我提供一种jq的解决方法
jss='$("input[name=\'starttime\']").val("2018-12-22")' 执行该语句 具体意思就去查jq