I have two ArrayList of String which I want to compare. Below is the code:
ArrayList<String> myData = objExcelData.GetRows("Dashboard", 1);
System.out.println(myData);
List<WebElement> uiList = driver
.findElements(By.xpath("//div[@class='machineblockdiv cursorpointer machinblockheight']//h4"));
ArrayList<String> lineText = new ArrayList<String>();
for (int i = 0; i < uiList.size(); i++) {
lineText.add(uiList.get(i).getText());
}
System.out.println(lineText);
This code gives me two lists i.e myData and lineText. The myData values are coming from an excel sheet and are getting stored in an arraylist of String. The lineText is coming from the web portal and is the text of web elements shown on portal. I want to compare the test data i am passing through excel and data shown on the portal. Both should match. If not then my test fails.
For example: My 'myData' array consists of {Airway, Finsuc, milestone} and my 'lineText' arraylist consists of {milestone, Jet}. So this test should fail as all the values are not same in both Array lists.
After comparing these I want to put an assertion in my TestNg code as well. Please help.