← Back to Discord Forum

Trying to validate my URL

got this error

Call log:

  • expect.toHaveURL with timeout 60000ms
  • waiting for locator(':root')

This thread is trying to answer question "How to validate a URL without encountering a timeout error?"

37 replies


any additional info you could share? code and/or DOM?

@mookiept ok will share DOM

@mookiept Error: Timed out 60000ms waiting for expect(received).toHaveURL(expected)

Expected string: "https://uk.minipilot.com/review/mymagicapp.com" Received string: "https://dev.mymagicapp.com/how-it-works/source-program" Call log:

@mookiept ?

if you run with headless mode off, what does it look like? How about the trace, any clues?

trace: 'on-first-retry',

  • expect.toHaveURL with timeout 60000ms
    • waiting for locator(':root')

what I meant was if you do something like await page.pause(); before the expect for the URL check, how does it look like? Also, when you're paused, run the following on the console and see what the result is: $$(':root')[0].baseURI

Wow Andre I don’t really know to go about this

ok, let's go back a bit. Do you know how to run with headless: false ?

that's one way, you can also enable UI mode: https://playwright.dev/docs/test-ui-mode

once you do that, you can modify your code like this (or go step by step, add a breakpoint, whatever you prefer):

// other code
await this.page.pause();
await expect(this.page).toHaveURL('TheURL');

execution will pause just before the assertion and you can check if:

  1. The URL on the browser looks like the one you expect
  2. If you go to the browser console, type $$(':root')[0].baseURI and seen which URL you are actually getting


@mookiept hello adre, after inputing this $$(':root')[0].baseURI i got the exact URL my page navigated to

is the unexpected one?

no expected one

that's odd 😬 can you insert temporarily a await this.page.waitForTimeout(2000); instead of the pause part and see if it passes

just to debug and see if things are moving too fast somehow or some other weird reason

Thanks will give it a try

still fails. there's this weird light that overlays on the screen before it fails

a light?

it's normal but why does this test keeps failing

could be that you're checking the wrong page fixture? 100% sure that this.page represents the correct page that you want to check the URL? please try console.info(await this.page.context().pages().length); just to see if you have more than one page in the same context or something

i've been validating several URL's on this page sir

i'll give this a try

Hello there, the page still refuse to navigate

what's the output of the console command from earlier?

hello @mookiept what i'm trying to validate is, when i click on a button it's open new page and i want to validate new page url

The button triggers a new page entirely



Hi @_godsown , by the way, how to config with timeout 60000ms? I set timeout in waitForUrl(..., timeout = 60000) but when timeout logs it still 30000ms

I'm aware, so if a new page fixture is triggered, you'd need to validate the URL on said page (if that's the one). Does await this.page.context().pages().length output 1 or 2 (or more)?

btw, not sure if I missed this or hasn't been asked yet: which version of Playwright are you using? I recall some bug on toHaveURL() on version 1.26 or so.

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 luc@ray.run.