a problem with Chromium and/or Browser Library has been driving me crazy for a few weeks now. We are automating test cases where in some rare cases an alert needs to be acted upon. Previously, we always used Selenium, with which this was not a problem. Since our switch to BrowserLibrary, we have observed strange behaviour in relation to alerts. If Chromium is started via Robot Framework, no alerts are displayed at all. If I start Chromium via the binaries installed by BrowserLibrary and carry out exactly the same steps manually, an alert is displayed. I have been able to reproduce this with JSFiddle and via the Dev Console and am at my wit’s end. Interestingly, I can execute JS commands as normal in the Dev Console, but the alerts won’t work. From my point of view it should make no difference at all whether I start Chromium manually or with RF?
I have attached a screenshot to illustrate the problem and would be very happy to receive help or further starting points.
@Axel This is very strange. I’m able to reproduce this behaviour. What’s also strange that it’s an Robot Framework / Browser Library issue. Because when I let Playwright JS open a Chromium browser I’m able to generate an alert by a JS command. But that same command executed in a Chromium browser opened by Browser library, doesn’t work.
Isn’t this a behaviour of Playwright ? @ Dialogs | Playwright, second paragraph says:
By default, dialogs are auto-dismissed by Playwright, so you don’t have to handle them. However, you can register a dialog handler before the action that triggers the dialog to either dialog.accept() or dialog.dismiss() it.
Handle next dialog on page with action.
Dialog can be any of alert, beforeunload, confirm or prompt. Handling dialogue must be called before the action, like example click, that triggers the dialogue.
If a handler is not set dialogs are dismissed by default.
So, i think @Axel – i think what you see is intended behaviour and you need to use that Handle Future Dialogs keyword if you need to change the dismissing to something else.
This doesn’t explain the difference between Chromium being launched by Playwright JS (where the JS alert command does work) and Chromium being launched by Browser Library (where the JS alert command doesn’t work).
Also you get an undefined message with the Chromium instance being launched by Browser Library
thank you very much, that really made the difference. The dialogue is handled and filled in.
I’m still a bit surprised that Playwright enforces such an approach to handling alerts and you don’t get these key UI elements displayed during debugging. But okay, there will certainly be reasons. The most important thing is that we can now continue with the implementation