执行高级设置 断言和数据提取
This commit is contained in:
@@ -8,6 +8,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
@@ -232,4 +233,14 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
}
|
||||
return endTime.getTime() - startTime.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期为 yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
public static String formatDateTime(Date date) {
|
||||
return date.toInstant()
|
||||
.atZone(ZoneId.systemDefault())
|
||||
.toLocalDateTime()
|
||||
.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -867,4 +867,41 @@ public class SeleniumUtils {
|
||||
driver.get(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据提取提取窗口信息
|
||||
* @param windowType
|
||||
* @return
|
||||
*/
|
||||
public String extractWindowInformation(String windowType) {
|
||||
switch (windowType) {
|
||||
case "1": // 窗口 Handle
|
||||
return driver.getWindowHandle();
|
||||
case "2": // 网页标题
|
||||
return driver.getTitle();
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid windowType: " + windowType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查找多个元素
|
||||
* @param locType
|
||||
* @param locValue
|
||||
* @return
|
||||
*/
|
||||
public List<WebElement> findElements(String locType, String locValue) {
|
||||
return driver.findElements(getLocator(locType, locValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取网页标题
|
||||
* @return
|
||||
*/
|
||||
public String getTitle(){
|
||||
return driver.getTitle();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user