Search code examples
javascriptplaywright

How to wait for a specific script to load on page in Playwright?


In Cypress, cy.intercept can be used for this purpose:

cy.intercept('GET', 'https://hello.com/script.js').as('scriptLoaded');
cy.wait('@scriptLoaded', {timeout: 20000});

How do I do that in Playwright?


Solution

  • Think what You are looking for are wait for request and/or response : https://playwright.dev/docs/api/class-page#page-wait-for-request