question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Allow Playwright to retrieve url from non existing pages.

See original GitHub issue

Hello, I made a similar question a month ago. Currently, I am testing sign-in functionality. Within the sign-in URL, there is a redirect URL that has functionality that when the user login successfully user gets redirected to the “redirect” URL with code, which later is used for other purposes. A redirect URL is not always an existing page, it is just a URL with code that has no content on it. Sometimes redirect URL does not even exist or it is just localhost with specific code on the end of the URL. With Playwright I am trying to sign in a user and then retrieve a redirect URL but somehow on the Chrome browser I only get this error: chrome-error://chromewebdata/ But when I run this same test with the headless feature turned off this is what I see: Picture: https://imgur.com/a/wl0XcJO Previous issue: #995 I assume that Chrome could not connect to the non-existing page but how could I get only the URL from that non-existing page? Is it even possible?

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
FragileYescommented, Aug 22, 2022

Hi Yury, I tried something page.waitingForUrl() but incorrect way as per your explanation Ill check it tomorrow. We are currently using HtmlUnit and urls are loaded directly to List <String> but trying to move to playwright.

Many thanks for explanation Best regards Juraj Valkovic

Dňa po 22. 8. 2022, 23:16 Yury Semikhatsky @.***> napísal(a):

From what you describe it the page is getting redirected to url containing auth code in which case you should be able to wait for the request https://playwright.dev/java/docs/api/class-page#page-wait-for-request, something like this:

Request request = page.waitForRequest("**/*callback?code=*", () -> {
    page.click(SUBMIT_BUTTON);
});
System.out.println(request.failure());

All the requests in the maps that you pointed at are dispatched to page.onRequest/onResponse etc listeners which is why I suggested using them before. The headers are available on the response objects:

page.onResponse(r -> {
  System.out.println(r.headerValue("location"));
});

Hope that helps.

— Reply to this email directly, view it on GitHub https://github.com/microsoft/playwright-java/issues/1035#issuecomment-1223067562, or unsubscribe https://github.com/notifications/unsubscribe-auth/A2UQPE33FIZWTLRKSGNDGALV2PU3XANCNFSM57ATPGYA . You are receiving this because you commented.Message ID: @.***>

0reactions
Sanadycommented, Aug 23, 2022

We managed to fix this issue with your solution. As you said before we established a listener on request waitForRequest . After that only what it did is to print out request.url() and we got redirected URL with an authentication code.

Thank you for your assistance Yuri, Best regards, Ivan Rener

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Playwright, page.url() is getting a previous url instead of ...
If url() already returns a string, then perhaps the missing await before page.url() could solve it? Please let us know if that works....
Read more >
Web Scraping with Playwright and Python - Scrapfly
Practical introduction to scraping dynamic websites and web apps with Playwright. Real life example project and common idioms and ...
Read more >
How to test web applications with Playwright and C# .NET
Open a browser and navigate to one of the localhost URLs.. You will see the home page with the button to open the...
Read more >
Migrating from Puppeteer to Playwright - Checkly
The switch from Puppeteer to Playwright is easy. But is it worth it? And how exactly does one migrate existing scripts from one...
Read more >
How To Run End-to-End Tests Using Playwright and Docker
Playwright is a great tool for end-to-end testing across browsers, ... there may be elements on the page that are not available, and, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found