When an asynchronous request returns before its result is ready, a busy-waiting loop repeatedly checks for completion until the result appears or a timeout occurs. Also called active waiting, busy looping, or polling, it is a simple way to synchronize automation code with asynchronous resources. section 21.4.1
Use polling with its costs and failure modes in mind:
- Avoid replacing polling with a fixed sleep: it can make test suites unnecessarily slow. Polling also adds repeated queries; shorter intervals increase that cost, while longer intervals can leave the test waiting after the result is ready. section 21.4.1
- Set a timeout rather than looping endlessly. If the operation does not produce a result in time, treat it as an error and fail the scenario. section 21.4.1
- Consider a Completed Event pattern when available; it synchronizes with a completion event and is usually more efficient than polling. section 21.5
Detecting a file update
If a request updates a file, the update might happen before the waiting loop begins. Capture the file’s status before requesting the operation, then compare it with the status during polling. section 21.4.1



