Rayrun
← Back to Discord Forum

How do you wait for the page to stop loading on the final page after all the Indirections?

I am trying to load the page, it redirect once or twice, and loads slow, currently I am using sleep which does not work good, so how do I make sure that my page has stopped loading?

This thread is trying to answer question "How do I make sure that my page has stopped loading after it redirects once or twice and loads slowly?"

6 replies
.aleksandaraleksandrov
.aleksandaraleksandrov

Hello Mohsan, in my exp. it's best to wait for the last API response or wait for one of the elements that loads the slowest.

API wait await page.waitForResponse("ulr")

Element wait const element = page.locator("element") await element.waitFor();

@.aleksandaraleksandrov But I do not know, what element to target to, as it may be available, an intermediate pages as well.

.aleksandaraleksandrov
.aleksandaraleksandrov

Can't you just check in the network tab for the api?

what do you mean?

.aleksandaraleksandrov
.aleksandaraleksandrov
AzdKYrbD5h.png
plays__with__squirrels
plays__with__squirrels

I also suggest looking at the API response. I tend to use expect_request and expect_response for actions that trigger an API call. Here is the link to their documentation. https://playwright.dev/python/docs/network

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