If you can actually see an alert dialog, then it can't be done. Selenium should handle it for you. But, as stated in Selenium documentation:
Selenium tries to conceal those dialogs from you (by replacing
window.alert, window.confirm and window.prompt) so they won’t stop the
execution of your page. If you’re seeing an alert pop-up, it’s
probably because it fired during the page load process, which is
usually too early for us to protect the page.
It is a known limitation of Selenium RC (and, therefore, Selenium IDE, too) and one of the reasons why Selenium 2 (WebDriver) was developed. If you want to catch onload
JS alerts, you need to use WebDriver alert handling.
That said, you can use Robot
or selenium.keyPressNative()
to fill in any text and press Enter and confirm the dialog blindly. It's not the cleanest way, but it could work. You won't be able to get the alert
message, however.
Robot
has all the useful keys mapped to constants, so that will be easy. With keyPressNative()
, you want to use 10
as value for pressing Enter or 27
for Esc since it works with ASCII codes.