This thread is trying to answer question "How can I assert that a print dialog opens up with 'Print' and 'Cancel' buttons visible after clicking a 'Print' button?"
Are you talking about the native print dialog/UI triggered when calling window.print()
?
I'm not sure why anyone but the browser vendors would want to validate that a core browser scenarios that's been working for 30+ years didn't break suddenly without anyone noticing. ๐ค
If you are talking about something else, yes locators and friends should do.
@p01___ I am talking about window.print() triggered dialog. Actually there is button "PDF" in UI code that triggers it. Sometimes back there was bug in the code and this dialog was not opening up when clicking the button in UI. So now it's fixed I am being told to write a test for it to just validate if clicking on "PDF" button opens up the print dialog. That's it. This is only I have to validate. Can you tell me how can I do that? The print dialog is a whole new page in itself and just doing a page.getByText("Print") or page.getByText("Cancel") (where "Print" and "Cancel" are buttons inside the native print dialog) is not working at all.
Right so that makes no sense to test that really.
You can't use locators because that's a native dialog. We don't have access to it or what's going inside it.
Did you try anything using the dialog event from Playwright?
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].