python - 使用 python 和 selenium 在日历中单击日期
问题描述
我很难弄清楚如何使用 Python 和 Selenium 在日历中单击开始和停止日期。下面是日历的 HTML 代码和它的外观截图。在日历中,您首先选择开始日期,然后选择结束日期,它会突出显示介于两者之间的所有内容。
<td class="day ng-binding ng-scope" ng-repeat="day in week" ng-class="{
'now':isNow(day),
'active':isSameDay(day),
'disabled':(day.getMonth()!=date.getMonth() || isDayDisabled(day)),
'after':isAfter(day),
'before':isBefore(day)
}" ng-click="setDate(day)" ng-bind="day.getDate()">6</td>
<th colspan="5" class="switch ng-binding" ng-click="setView('month')">2020 July</th>
<p class="cndrTitle ng-binding">Start Date</p>
<th colspan="5" class="switch ng-binding" ng-click="setView('month')">2020 July</th>
解决方案
public static void setcalender(String monthyear2, String date2,String monthyear3, String date3) {
// driver.findElement(By.id("xpath of month year")).click();
while (true) {
String CurrentMonth = driver.findElement(By.xpath("xpath of title]")).getText();
if (CurrentMonth.equals(monthyear2)) {
break;
} else {
// click next arrow option until get user input
driver.findElement(By.xpath("xpath")).click();
}
}
driver.findElement(By.linkText(date2)).click();
}
//click on thru date title
driver.findElement(By.id("xpath")).click();
while (true) {
String CurrentMonth = driver.findElement(By.xpath("your xpath]")).getText();
if (CurrentMonth.equals(monthyear3)) {
break;
} else {
// click next arrow until get date
driver.findElement(By.xpath("xpath)).click();
}
}
driver.findElement(By.linkText(date3)).click();
}
推荐阅读
- c# - 尝试在 Dot Net Core 2.0 中解码 JWT
- mongodb - mongodb中的unpivot分组列
- c# - 读取 Helpers 的 URL 参数
- php - 我如何在 php 中优化我的代码以进行循环
- qt - 如何在 qmake 生成过程中指定 pkgconfig 的 Libs 变量?
- javascript - 在 javascript 文件中设置 firebase-admin sdk
- java - Java Xpath在xml中排除孩子
- vue.js - vue.config.js 访问特定位置
- python - 张量流损失始终为 0.0
- java - Spring Boot 中@Async、@Scheduled 和线程池的正确使用