无法使用 selenium webdriver 选择日期,并且 HTML 代码用于日历
Posted
技术标签:
【中文标题】无法使用 selenium webdriver 选择日期,并且 HTML 代码用于日历【英文标题】:unbale to select date using selenium webdriver and HTML code is there for calendar 【发布时间】:2021-09-04 19:19:28 【问题描述】:enter image description here 下面是日期输入字段的 html。我无法检查日历。
【问题讨论】:
【参考方案1】:如果您只想send keys
到那个输入字段:
driver.findElement(By.id("enddate")).sendKeys("02/03/2005");
【讨论】:
【参考方案2】:如果要检查 DatePicker 是否存在,请传递 DatePicker 标题的定位器(例如:月份名称)并使用 if 条件
// Validate the title, so that you can find whether the date picker is present or not
if(monthname.isdisPlayed())
....
首先,找到它是什么类型的日期选择器。如果是 jQuery 日期选择器,你可以检查并处理它。
下图中显示的日历是一个 jQuery 日期选择器:
【讨论】:
以上是关于无法使用 selenium webdriver 选择日期,并且 HTML 代码用于日历的主要内容,如果未能解决你的问题,请参考以下文章