定位到该input;
使用send_keys方法改变日期值。
可能遇到的问题:从字符串转换日期和/或时间时,转换失败;
输入日期字符串与日期格式转换的问题,可以直接转到处理方式2
使用execute_script方法;
js语句:document.getElementById(IdName).value = 你想要输入的日期值("2021-08-01")
or document.getElementById(IdName).setAttribute(attribute,value) 其中attribute=元素属性,例如value;value=属性值,例如"2021-08-01"
使用JS删除readonly的属性:document.getElementById(IdName).removeAttribute("readonly")
WebElement dayElement=driver.findElement(By.xpath("//span[@id=‘from_imageClick‘]")); dayElement.click(); // WebElement frameElement=driver.findElement(By.xpath("//iframe[@border=‘0‘]")); driver.switchTo().frame(1); driver.findElement(By.xpath("//tr/td[@onclick=‘day_Click(2015,2,21);‘]")).click(); driver.switchTo().defaultContent();
原文:https://www.cnblogs.com/gocean/p/15222290.html