Check for a dialog box during process

I have an application that, after login, may sometimes present a dialog box that you would click on an 'ok' button to remove.
Other times the dialog box may not appear.
Is their any method to check if the dialog box appears then act on it accordingly?

With synthetics you have the full power of JS/TS scripting, so you could definitely do this. This section in the Playwright guide should help you solve this problem.

Thanks. Where would you suggest posting for Playwright code queries?

Hi Garry, when you ask about Playwright code queries do you mean where to post in order to obtain help related to using Playwright itself? Or do you mean selector queries to find elements?

If you're referring to the first, I'd probably recommend using the playwright tag on StackOverflow or the GitHub repo for Playwright.

If you referring to the second, I'd have a look at this page.

The issue I have is if I use the elastic recorder I get the following section auto generated...

await Promise.all([
page.waitForNavigation(/{ url: 'https://xxxxxxxxxxxxx' }/),
page.frame({
name: 'AxDojo_Dialog_frame_1643298237258'
}).click('text=OK')
]);

'AxDojo_Dialog_frame_1643298237258' changes however it always contains/starts with 'AxDojo_Dialog_frame'

I was thinking something along the lines of
name: 'contains ('AxDojo_Dialog_frame')'

However i can't seem to get the syntax correct.
Any ideas?

Hey Garry,

It seems like it's not possible to use a RegEx on the page.frame function itself, but it seems like it's possible to list frames with the page.frames API (Page | Playwright). You could use that and then .filter using the desired regular expression or rule to choose the desired frame(s).

Overall, I'd really recommend Playwright's docs, they contain a great level of detail and quite a few useful examples.

This topic was automatically closed 24 days after the last reply. New replies are no longer allowed.