UI报告接口
This commit is contained in:
@@ -186,4 +186,50 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
|
||||
return Date.from(zdt.toInstant());
|
||||
}
|
||||
|
||||
public static String calculateTimeDifference(Date startTime, Date endTime) {
|
||||
long diffInMillis = endTime.getTime() - startTime.getTime(); // 获取时间差(毫秒)
|
||||
long totalSeconds = diffInMillis / 1000; // 转换为秒
|
||||
long totalMinutes = totalSeconds / 60; // 转换为分钟
|
||||
long totalHours = totalMinutes / 60; // 转换为小时
|
||||
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
// 如果时间差超过1小时
|
||||
if (totalHours > 0) {
|
||||
result.append(totalHours).append("h");
|
||||
long remainingMinutes = totalMinutes % 60; // 剩余的分钟
|
||||
if (remainingMinutes > 0) {
|
||||
result.append(remainingMinutes).append("min");
|
||||
}
|
||||
long remainingSeconds = totalSeconds % 60; // 剩余的秒
|
||||
if (remainingSeconds > 0) {
|
||||
result.append(remainingSeconds).append("s");
|
||||
}
|
||||
} else if (totalMinutes > 0) { // 如果时间差在1分钟到1小时之间
|
||||
result.append(totalMinutes).append("min");
|
||||
long remainingSeconds = totalSeconds % 60; // 剩余的秒
|
||||
if (remainingSeconds > 0) {
|
||||
result.append(remainingSeconds).append("s");
|
||||
}
|
||||
} else { // 如果时间差小于1分钟
|
||||
result.append(totalSeconds).append("s");
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个时间点的时间差(单位为毫秒)
|
||||
*
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @return 时间差(单位为毫秒)
|
||||
*/
|
||||
public static long differenceInMilliseconds(Date startTime, Date endTime) {
|
||||
if (startTime == null || endTime == null) {
|
||||
throw new IllegalArgumentException("开始时间和结束时间不能为空");
|
||||
}
|
||||
return endTime.getTime() - startTime.getTime();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ public class SeleniumUtils {
|
||||
this.wait = new WebDriverWait(driver, Duration.ofSeconds(10));
|
||||
this.actions = new Actions(driver);
|
||||
}
|
||||
|
||||
// 设置显式等待超时时间
|
||||
public void setWaitTimeout(long seconds) {
|
||||
this.wait = new WebDriverWait(driver, Duration.ofSeconds(seconds));
|
||||
|
||||
Reference in New Issue
Block a user