How to verify the page source before and after refreshing
briley last edited by
How to verify the page source before and after refreshing and how to print the both the page sources
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.