In the date control, the input control of the date control is generally not entered manually; just remove the ReadOnly attribute.
Actually very simple, we do not make time date space, we treat it as a normal input box to deal with it!
However, a lot of this type of input box is forbidden to enter manually, what to do?
Very simple, with JS to prohibit the input of the ReadOnly attribute removed just fine. Here are four ways to
#-*-coding:utf-8-*-from Selenium Import webdriverfrom time Import sleepdriver = Webdriver. Firefox () Driver.get (' http://www.sucaijiayuan.com/api/demo.php?url=/demo/20141108-1/') driver.switch_to.frame (' iframe ')# JS ="document.getElementById (' txtbegindate '). RemoveAttribute (' readonly ')"#1. Native JS, remove attributes# js = "$ (' input[id=txtbegindate] '). Removeattr (' readonly ')" Span class= "Hljs-array" ># 2.jquery, removing properties # js = " $ (' input[id=txtbegindate] '). attr (' readonly ', False) "# 3.jquery, set to Falsejs = "$ (' input[id=txtbegindate] '). attr (' ReadOnly ', ') "# 4.jquery, set to empty (same as ' 2016-08-24 ') sleep (2) print driver.find_element_by_id ( Txtbegindate '). Get_attribute ( ' value ') driver.quit ()
Original article Address: http://www.infocool.net/kb/Python/201608/184024.html
How the date control is handled when writing scripts in the Python language