Search code examples
seleniumselenium-webdriverwebdriverprotractorpageload

Best way to automate a page and check if it is loaded correctly


I am looking to verify if this page loads correctly - http://www2.hm.com/en_ca/women.html

These are the things I think it would be best to verify if the page is loaded correctly, please let me know if I am missing anything

1) Verify all the links on this page works?

2) Verify if the menu on the top is loaded correctly, Do I need to verify the menu names?

3) Check if the classes are loaded properly?

4) get/post request status 200 and other ajax calls?


Solution

  • As per your question a seperate test to check if the page is loaded correctly will be a complete overhead because the Client (i.e. the Web Browser) will never return the Execution Control back to the WebDriver instance until and unless 'document.readyState' is equal to "complete". Once this condition is fulfilled Selenium performs the next line of code.

    You can find a detailed discussion on this topic in Selenium IE WebDriver only works while debugging

    Next as you want to Verify if all the links on this page works or not , you can write a function() and invoke the function() whereever required.

    Moving on to next question, there is no necessity to Verify if the menu on the top is loaded correctly or not as you can't test each and every aspect of each and every WebElement present on a WebPage. The best approach would be to verify and validate the attributes of only those elements with whom we need to interact.

    Again Checking if the classes are loaded properly will be a overhead as JVM takes care of it in the best possible way.

    Finally, to validate get/post request status 200 you have to write Tests as per your requirement.