Rather than using methods like waitForPageToComplete() or document.readyState property etc. to wait for a page to load in your Se tests, the better way is to use the LoadableComponent and SlowLoadableComponent pattern in Page Object Model.
You need to make sure that your Page Object classes extends the abstract LoadableComponent class which in turn provides the implementation for the following methods:
- load() //The load method is used to navigate to the page
- isLoaded() throws java.lang.Error //The isLoaded method is used to determine whether we are on the right page.
The get() method from the LoadableComponent class will ensure that the page/component is loaded by invoking the isLoaded() method. If the check fails here, load() method is called followed by isLoaded().
If your site loads very slow, then we should consider using SlowLoadableComponent instead of LoadableComponent. SlowLoadableComponent verifies the page is loaded until the given maximum timeout. It extends the LoadableComponent class.
#selenium #testAutomation #automationTesting #pageObjectModel #slowUITest
Comments
Post a Comment