Test Code: index.js
This example shows how to use an assertion to pause the test until an element's width is 100%
.
The tested page in index.html
displays a progress bar that runs from 0%
to 100%
. The index.js
file defines a client function that retrieves the bar's width. The test asserts that this client function returns 100%
.
When this assertion is executed, TestCafe activates the Smart Assertion Query Mechanism that waits until the assertion passes. When the element's width reaches 100%
, the test resumes. If the progress bar does not fill within the timeout (30 seconds), the assertion fails.