How to compare two list values

Hi All…

I have list of values from excell which i need to verify with the expected list of values in mobile UI which i have kept in a list…
Please have a look in to the code below…

List WebElementValue = listOf_element_From_UI;
List excell_ExpectedList= listOf_element_From_Excell;

	Thread.sleep(2000);
	
	try
	{
	for(int j=0; j<excell_ExpectedList.size();j++)
		{
		System.out.println("Size of Data in Excel Sheet"+expectedList_dateFromExcell.size());
		System.out.println(":"+WebElementValue+":  From Web Eleement and :"+expectedList_dateFromExcell +":  From Excel");
			if (excell_ExpectedList.contains(WebElementValue ))
					{
				     System.out.println("Data Verified");
				     break;
					}
			else
			{
				System.out.println("Data Mismatch not Verified");
				continue;
			}
		}

but its not validating against all values from the excell sheet… if say the first row of value is invalided and rest of the rows are valid, it’s not validating for other values…

iam getting following result as

Index: 4, Size: 4
Size of Data in Excel Sheet4
:[Saving, Primary, Carded, 12312312312312]: From Web Eleement and :[Saving, Primary, Carded, 12312312312312]: From Excel
Data Mismatch not Verified
Size of Data in Excel Sheet4
:[Saving, Primary, Carded, 12312312312312]: From Web Eleement and :[Saving, Primary, Carded, 12312312312312]: From Excel
Data Mismatch not Verified
as per the test data, the values from excell and ui are same and it should have passed… but it switch to the else part

Appreciate if anyone can give better idea on same…

Thanks

@Aleksei @kcinman11358 @anish10110 @narendarsingam @crujzo @upendraupadhyay any idea please


Thanks

say what you need more exactly pls. also you can try - http://stackoverflow.com/questions/2762093/java-compare-two-lists

1 Like

I believe the article will help. Thanks @Aleksei
@hariumesh this forum is for Appium related discussions. We would much appreciate if you post your queries related to Appium Only .

Thank you @Aleksei and @crujzo… sure… will make sure to make query related to appium…
anyway… i am facing an issue in taking screeen shot … but it throw the error for the following code…

String folderName = “screenShot”;
File srcfile =driver.getScreenshotAs(OutputType.FILE);
new File(folderName).mkdir();
FileUtils.copyFile(srcfile, new File(folderName));

error as…

java.io.IOException: Destination ‘screenShot’ exists but is a directory
iam trying to create a directory where the screen shot will be stored… let me know what would be the wrong in the code

Thanks

Again, this isn’t an Appium issue. This is a coding logic issue. Please search around for how to create a folder, file, etc in Java.