Rayrun
← Back to Discord Forum

page.goto(url1) redirect to another url2 when the page is loading

Hi everyone! I'm working on a scenario in which:

  1. Call an API endpoint to get a redirect link (url1).
  2. The redirect link is required to be opened by a browser to redirect to the second URL:
await page.waitForURL(url2);

Now, by running the test, it stuck at loading URL 1 and couldn't redirect to URL 2. I tried to increase the timeout, but it still didn't work.

I tried to call an API endpoint on Postman to get redirectedLink and open a new tab next to the tab that the test is loading. By pausing the URL and entering, I could get redirected to the second URL.

Any answer would be greatly appreciated!

This thread is trying to answer question "Why does page.goto(url1) not redirect to url2 when the page is loading, and how can this issue be resolved?"

2 replies

Could it be caused by redirecting across domains?

Hey,

My thoughts

  • Check the network acitivity - Is it waiting for some network activity before redirecting?
  • If it is redirecting via JS you may need to explicitly use page.waitForNavigation()
  • Use page.on('pageerror', console.error) to check for page errors

Related Discord Threads

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].