How to verify the page source before and after refreshing and how to print the both the page sources
closed as unclear what you're asking by Nitin Rastogi, trashpanda, Niels van Reijmersdal, IAmMilinPatel, Bharat Mane Apr 19 at 7:56
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
The quick answer is:
String before = driver.getPageSource(); // Do whatever for page refresh // Make sure there is a delay for the whole page to load String after = driver.getPageSource(); assertFalse("ERR: Source is the same", after.equals(before));
There are much better ways to do comparisons but you should get the idea.
Comparing the entire source is a very hacky way to check for a refresh. It would be better if you looked for a specific element within the page to change, like a timestamp.