How can I compare both list is equal Verify data is from Excel sheet. I need to validate both list are same and there is no additional element or missing element from the list. I don't require to sorting the list. And Print output CAGID Excel data = CAGID web list
String[] Verify1 = Verify.split(",");
for(String actualView1 : Verify1) {
System.out.println("string" + actualView1);
}
List<WebElement> options = driver.findElements(By.xpath(SUMMARYFIELDS));
for (WebElement ele : options) {
System.out.println(ele.getText());
}
Output String
string CAGID
string GFPID
string IRU
string Control Unit
string Obligor Classification
string Obligor Limit Rating
string Obligor Risk Rating
string Commentary
string Credit Officer
string Risk Manager
string RCA Date
string RCA Extension Date
Output ele.getText()
CAGID
GFPID
IRU
Control Unit
Obligor Classification
Obligor Limit Rating
Obligor Risk Rating
Commentary
Credit Officer
Risk Manager
RCA Date
RCA Extension Date
If you don't bother about the order, then collect all text from WebElement
to List<String>
List<String> text = options.stream().map(WebElement::getText).collect(Collectors.toList());
Then now just compare by using equals()
System.out.println(text.equals(Arrays.asList(verify1)); // use naming convention for variables
Note This approach is case sensitive
Not really elegant but I thinks it's works
String[] Verify1 = Verify.split(",");
List<WebElement> options = driver.findElements(By.xpath(SUMMARYFIELDS));
boolean isOK = true;
for (WebElement ele : options) {
int i = Arrays.asList(Verify1).indexOf("string "+ele.getText())
if(i==-1){
isOK=false;
}
else{
System.out.println(Verify1[i]" Excel data = "+ ele.getText()+" web list");
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.