Playwright Wait for URL

Profile picture for user arilio666

waitForUrl() method is used by the playwright to wait for the specified URL till it stops loading and completes fully.


await page.waitForURL(url);

Arguments Used:

Url:  string|RegExp|function(URL)

A glob pattern or any regex pattern receiving URL is provided to match while waiting for the navigation.


 timeout: Maximum time taken in milliseconds default is 30 seconds.

waitUntil "load"|"domcontentloaded"|"networkidle"|"commit"

domcontentloaded: Operation to be finished when the domcontentloaded event is fired.
load: Operation to be completed when the load is fired.
networkidle: Operation to be completed when networkidle is fired when there are no network connections.
commit: Operation to be completed when network response is received, and the doc starts loading.


await page.goto('');
             await page.locator('.fa-search').click()
          await page.locator('#edit-keys').type('Playwright')
          await page.locator('#edit-submit').click()
          await page.waitForURL('')           
  • Here we used waitForURL to the URL where when clicked on the search bar 'go.'
  • This will wait for the specified URL and then prepares the page for other operations.