I have two array lists,expectedResult and actualResults.
List<String> expectedResult = new ArrayList<String>();
expectedResult.add("2014-11-17");
expectedResult.add("2014-11-18");
expectedResult.add("Active");
expectedResult.add("Manual");
expectedResult.add("Android WarZone");
expectedResult.add("Android Headlines");
List<String> actualResult = new ArrayList<String>();
WebElement table = driver1.findElement(By.id("keyword-grid"));
List<WebElement> allCells = table.findElements(By.tagName("td"));
for (int j=0; j<allCells.size(); j++){
actualResult.add(allCells.get(j).getText());
}
Actual data set is as below.
[Android WarZone, Manual, Active, 2014-11-18 12:21:45, Digitalbox Testing, , Android Headlines, Manual, Active, 2014-11-18 10:25:36, Digitalbox Testing, ]
I am trying to compare the two array list values using below code.
for(int i=0;i<expectedResult.size();i++) {
if(actualResult.get(i).contains(expectedResult.get(i))) {
System.out.println("Search function verified");
}else {
System.out.println("Search function verification failed"+actualResult.get(i));
}
}
below is the output of the comparison.
Search function verification failedAndroid WarZone
Search function verification failedManual
Search function verified
Search function verification failed2014-11-18 12:21:45
Search function verification failedDigitalbox Testing
Search function verification failed
Only one value, Android Headlines, was verified.
How can I compare two array values?