因为一些input标签,具有readonly属性,我们去要去掉readonly属性,才能实现对input标签的输入;一开始的时候我在网上查了很对资料,最终实现了,不多说了,直接上代码:
#开始日期
# js = 'document.getElementsByClassName("ant-calendar-picker-input ant-input")[0].removeAttribute("readOnly")'.format("//*[@id='root']/div/div[2]/div/div[2]/div/div/div/div/div[2]/div[2]/div/div/div[1]/div/form/div[2]/div/div/span/span/input") # 使用js临时移除readonly属性
js = 'document.getElementsByClassName("ant-calendar-picker-input ant-input")[0].removeAttribute("readOnly")'
self.driver.execute_script(js) # 执行js
time.sleep(1)
self.driver.find_element(By.XPATH,"//*[@id='root']/div/div[2]/div/div[2]/div/div/div/div/div[2]/div[2]/div/div/div[1]/div/form/div[2]/div/div/span/span/input") .clear()
time.sleep(1)
# self.driver.find_element