Take the 2-minute tour ×

I am trying to automate one website, in my project after clicking on 'submit' button, one alert message with ok button will come. I want to click that ok button.

I tried with these two codes seperatly but these are not working

                    AlertDialogHandler AlertDialog = new AlertDialogHandler();

                    var AlertDialogHandler = new AlertDialogHandler();
                    using (new UseDialogOnce(ie.DialogWatcher, AlertDialogHandler))
                        var message = AlertDialogHandler.Message;

While using these two codes, I got the same exception 'dialog not available within 30 seconds'.

Any help will be deeply appreciated. Thank You :)

share|improve this question
add comment

4 Answers

This has happened with me a couple of times when I had multiple browser windows open and I was trying it out.
The solution at that time was to close all instances of IE, close NUnit / VS and start over again, and it worked like a charm. However, I was using a ConfirmDialogHandler and not an AlertDialog Handler.

If that does not help you might want to try adding the following before you fire up your browser instance.

Settings.AutoStartDialogWatcher = true;
Settings.AutoCloseDialogs = true;
share|improve this answer
add comment

I'm not familiar with WatiN, but here's another SO post that might help:

WatiN seems to not find JavaScript alert

share|improve this answer
add comment

There is a way to perform this without watin:

See my post:

Need a way to perform auto confirm for firefox or any other browser popup's

share|improve this answer
add comment

this is slightly unrelated but AlertDialogHandler's don't work for Firefox but there is a workaround...


share|improve this answer
add comment

Your Answer


