Rayrun
← Back to Discord Forum

Is there a way to create a promise that just will click a button if it appears?

captainjetskiposted in #help-playwright
Open in Discord
captainjetski
captainjetski

I have a web app that has a pendo guide injected into it. I unfortunately cannot turn these off so I have to handle them as they appear.

Is there a way to just create something that sits and waits for an element then only clicks it if it appears? In my case the element may or may not appear

This thread is trying to answer question ""

3 replies
tphillips8117

You could do it a number of ways. You can use the or() method of a locator: https://playwright.dev/docs/api/class-locator#locator-or Or you can use await expect(pendoLocator).toBeVisible() in a try ... catch to catch the exception and continue if it doesn't appear

captainjetski
captainjetski

thank you! I'll give it a shot today and report back

I have solved similar with listening to IFrame navigation events

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.