The Wait for Page Ready action has several readiness states to choose from, giving you the ability to fine-tune when the action should consider a page to be 'ready.' The selection of the readiness state depends on the specific requirements of your test scenario:
- Load: This readiness state ensures that the load event of a webpage has fired. The load event is fired when the whole page has loaded, including all dependent resources such as stylesheets, images, and scripts. Using the Load readiness state is crucial when your testing scenario requires interacting with or validating elements that depend on resources loaded last.
- DOMContentLoaded: This readiness state waits for the DOMContentLoaded event, which fires when the initial HTML document has been completely loaded and parsed, without waiting for stylesheets, images, and subframes to finish loading. This state can be useful when your testing scenario involves interactions with elements that don't depend on the complete load of other resources.
- NetworkIdle: This readiness state considers a page to be ready when there are no more than 2 network connections for at least 500 ms. This state is especially helpful when testing scenarios involving pages that do a lot of background loading via AJAX requests or similar after the load event fires. The NetworkIdle state ensures that all these background loading tasks have finished, ensuring the stability of the test scenario.
By using the appropriate readiness state in the Wait for Page Ready action, you can ensure that your tests are more robust and less prone to intermittent failures due to timing issues or incomplete page loads. Consequently, this enhances the reliability of your test results and makes your automated web testing more efficient and effective.