← Back to Discord Forum

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

shashanktiwari_82156posted in #help-playwright
Open in Discord

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.


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

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


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

cool, this works , Thank you @dirvinautomation_16636 🙂


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

Related Discord Threads

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.