Testing strange web applications using Selenium? Take note.

Update to: Workaround for alert() and confirm() during onload()

A change in Selenium has caused this workaround to stop working for those inclined to simply copy and paste Alistair's original solution. These days, if you want to give Selenium access to alert() and confirm() dialogs your application pops up during the onload event, you'll need to reference parent.selenium.browserbot instead. As per the original solution, execute the following code anywhere (either statically in the page or in the onload event itself) before the JavaScript which pops up a dialog:

var browserbot = parent.selenium.browserbot;
if (browserbot) {
browserbot.modifyWindowToRecordPopUpDialogs(window, browserbot);

Tada! You're home free and your QAs can happily automate testing through the UI once again.

Also of note: If you're popping up alert and confirm dialogs in an IFrame (egads!), you'll need to reference parent.parent.selenium.browserbot.

Happy testing!

No comments: