What causes issues with page.waitForTimeout in Playwright?

I’m currently working on a test automation project using Playwright on Windows 10 with the latest Chromium version. I attempted to use the page.waitForTimeout method to introduce a delay between actions, but it doesn’t seem to be working as expected. For some reason, the method does not pause the execution, and the script continues running instantly. I was expecting a delay of several seconds, but it appears to be ignored. I’ve double-checked to ensure I’ve set the timeout correctly as an integer. Could anyone shed light on what might be going wrong or suggest alternative approaches?

Running into issues with page.waitForTimeout in Playwright is fairly common, especially when dealing with asynchronous code. Often the problem comes from not properly awaiting the function call.

Since Playwright methods are asynchronous, the delay will only occur if the call is preceded by await. If the promise isn’t awaited, the script will continue executing immediately.

Here is the snippet that worked for me:

await page.waitForTimeout(3000);

This pauses execution for 3 seconds before moving on to the next line.

Make sure the function containing this line is declared as async and that all asynchronous Playwright calls are awaited properly. Missing an await is one of the most common causes of this issue.

Also review your script to ensure there are no other asynchronous operations running in parallel that might make it seem like the delay is being skipped.

I experienced something similar and realized the issue came from misunderstanding how waitForTimeout behaves within asynchronous workflows.

page.waitForTimeout is essentially a simple delay. In some test setups or frameworks, other async operations or test runners might continue executing in parallel, making the pause seem ineffective.

A simple JavaScript alternative is using a manual promise-based delay:

await new Promise(resolve => setTimeout(resolve, 3000));

This creates a 3-second delay using native JavaScript promises.

However, it’s worth considering whether you actually need a fixed delay. In many cases, waiting for a specific condition—like an element appearing or a network request finishing—is more reliable than pausing execution for a fixed amount of time.