Rayrun
← Back to Discord Forum

page.reload to wait for some text to be appeared on UI.

shashanktiwari_82156posted in #help-playwright
Open in Discord
shashanktiwari_82156

Hi, I have a scenario where I have to refresh page 2-3 times to see some text on UI. is there a way ? where during every poll , page reload will be called and check for some condition if that condition does not meet then again reload the page.

thanks

This thread is trying to answer question "Is there a way to refresh a page multiple times until a certain condition is met?"

3 replies
dirvinautomation_16636

Yes, you can use toPass, which accepts a callback function to be run repeatedly until it passes (or until the expect timeout has passed.

EX:

await expect(async () => {
  await page.reload()
  await expect(page.getByText("some text")).toBeVisible()
}).toPass({ timeout: 10_000 })
shashanktiwari_82156

cool, this works , Thank you @dirvinautomation_16636 🙂

shashanktiwari_82156

I just added timeout inside toBeVisible({timeout:2000)

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.