【发布时间】:2020-09-17 13:29:56
【问题描述】:
我有一个存储在列表中的预期 WebElement 和实际 WebElement 列表。我想对两个列表进行排序并将预期与实际的 WebElements 进行比较。
下面是我写的代码。
List<WebElement> ExpList = List.of(LookingLbl,GenderLbl,MandatoryList,NameLbl,MobLbl );
System.out.println("Expected list size is : " +ExpList.size());
System.out.println("Expected list of Web Elements below : ");
for(WebElement expElem : ExpList) {
System.out.println(expElem.getText());
}
List<WebElement> ActList = driver.findElements(By.xpath("//h3[contains(text(),'')]"));
System.out.println("WebElement list size is :" +ActList.size());
System.out.println("Actual list of Web Elements below : ");
for(WebElement elem : ActList) {
if(elem.getText().contains("*")) {
System.out.println(elem.getText());
}
}
现在我希望对 ExpList 和 ActList 进行排序和比较。如何对实际和预期的网络元素进行排序和比较?
【问题讨论】:
标签: java selenium selenium-webdriver arraylist webdriver