Rayrun
← Back to Discord Forum

Any best methods for waiting for an input to reload page content?

In testing a webpage, I’ve changed the value of a “select option” element which filters the table on the page to only show matching data etc. After changing the value I use a locator to determine how many rows are in the table, and then I loop through the rows to confirm they match the filter. My issue right now is that because the next JavaScript lines don’t wait for the page to actually change from the initial table, the following Java script normally gets about halfway done before the table even changes. I am able to make it work with a “page.waitForURL” line after the action, but that is only because the specific filters are easily readable from the url. And I would like to have a better practice that is more widely applicable. Is there a best practice for waiting for the page content to respond to an action?

This thread is trying to answer question "Is there a best practice for waiting for the page content to respond to an action?"

7 replies
tphillips8117

see if the 'domcontentloaded' or 'networkidle' options work

tphillips8117

note that 'networkidle' is discouraged however

tphillips8117

(assuming there's nothing else on the page that changes when it's done loading)

.aleksandaraleksandrov
.aleksandaraleksandrov

Try "await page.waitForResponse("Your API");" that is giving you the data, but this is depending on the app. you can even try with simple waitForTimeout, which is less advisable. But if it work, it works 🙂

@.aleksandaraleksandrov: We are looking for more consistent alternatives to “waitfortimeout” but I am hoping I can get the wait for api response working because the waitForLoadState(‘networkidle’) seems to consistently take about twice as long as the wait for URL option

We are looking for more consistent alternatives to “waitfortimeout” but I am hoping I can get the wait for api response working because the waitForLoadState(‘networkidle’) seems to consistently take about twice as long as the wait for URL option

.aleksandaraleksandrov
.aleksandaraleksandrov

Different apps, work in different ways, so I hope you find a way. I almost always use the API wait and it works, but not always 🙂

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