To compare 2 XML files with selenium, we can use the available utilities. For example, XMLUnit can be used for comparison in Java and XMLDiffPatch with C#.
Below is a sample program to perform XML comparison in C#:
- If we are using Visual Studio, we need to download XMLDiffPatch NuGet package.
- Then write the below statements in your program to perform the simple comparison.
XmlDiff xmlcompare = new XmlDiff();
bool bIdentical = xmldiff.Compare(expectedxml, actualxml);
- Here bIdentical will return true if data matches and false if there is any mismatch.
- XML files can also be read from a local system using XMLReader.
- Similarly, there are other capabilities of this package that can be used to perform XML handling if needed.
Need reliable QA resources to ramp up your existing processes?