Playwright Wait For Navigation

In this article, we are gonna see about the wait for navigation method in playwright. When a certain link is clicked and it navigates to a new page we can use the page.waitForNavigation() till the page gets navigated and action is performed.

const [response] = await Promise.all([
  • To avoid race condition this is wrapped inside the promise function which will wait until navigations get completed and then performs the next provided operation.
  • page.waitForNavigation() waits explicitly for the event to happen and continues.
  • This is actually from the puppeteer and the playwright offers the same API for waiting on events and elements.
    page.waitForNavigation() is similar to page.reload() and goBack().
page.waitForNavigation({ timeout: 2000 })
  • The timeout can be set inside the waitForNavigation as an option to hard timeout.
Thu, 12/29/2022 - 13:43
Ashwin possesses over five years of experience in the Quality Assurance industry and is currently serving as a Technical Lead at iVagus. His expertise encompasses a broad range of technologies, including Cypress, Rest Assured, Selenium, Cucumber, JavaScript and TypeScript.