Rayrun
← Back to Discord Forum

cypress to playwright

cy.location().should(location => {
expect(location.pathname).to.eq('/reset_password');
expect(location.search).to.eq(?token=${TOKEN});
}); any one know how to write in playwright

This thread is trying to answer question "How to write a location check in Playwright similar to Cypress?"

2 replies

Hi Try this:

const { pathname, search } = await page.evaluate(() => ({
  pathname: window.location.pathname,
  search: window.location.search,
}))

expect(pathname).toBe('/reset_password')
expect(search).toBe('?token=${TOKEN}')

thankyou

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].