时间控件_Selenium时间控件的处理
生活随笔
收集整理的這篇文章主要介紹了
时间控件_Selenium时间控件的处理
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
我們經(jīng)常在做web自動化測試過程中會遇到時間控件,那么對于時間控件如何處理,我們可以來分析下。
對于時間控件一般分為兩種:
1、普通的時間控件
直接通過send_keys就可以解決
d.get("https://www.ctrip.com/?sid=155952&allianceid=4897&ouid=index") time.sleep(10) ele = d.find_element_by_id('HD_CheckIn') ele.clear() ele.send_keys('2019-06-03')eleout = d.find_element_by_id('HD_CheckOut') eleout.clear()2、時間控件屬性readonly='readonly'的
js = "document.getElementById('noticeEndTime').removeAttribute('readonly')"
#js = "document.getElementsByName('noticeEndTime')[0].removeAttribute('readonly')"
#js = "document.getElementsByTagName('input')[0].removeAttribute('readonly')"
d.execute_script(js)
d.find_element_by_name("noticeEndTime").send_keys("2019-06-21 10:52:52")
通過js去去掉readonly然后再去輸入就沒問題了。
總結(jié)
以上是生活随笔為你收集整理的时间控件_Selenium时间控件的处理的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python 任务调度 celery_p
- 下一篇: 6 获取数组中最小值_C语言每日一练8—