我有一个带有文本框字段的网页。它附近的日历图标。当我单击日历图标时,会显示一个日历 View 。我认为它不是 jquery 日历。任何人都可以提供一个例子来自动化这种类型的日期选择器。
最佳答案
我试过这段代码,它也可能对你有用:
DateFormat dateFormat2 = new SimpleDateFormat("dd");
Date date2 = new Date();
String today = dateFormat2.format(date2);
//find the calendar
WebElement dateWidget = driver.findElement(By.id("dp-calendar"));
List<WebElement> columns=dateWidget.findElements(By.tagName("td"));
//comparing the text of cell with today's date and clicking it.
for (WebElement cell : columns)
{
if (cell.getText().equals(today))
{
cell.click();
break;
}
}
关于testing - 使用 Selenium webdriver 从日期选择器中选择一个日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21398575/