Handling Alert Boxes

Mar 19, 2014 at 6:03 PM

I am working with an HTML page which has a button. When the button is clicked, I get a Javascript confirm box. I need to click on OK button, which I can handle using something like:
But, under certain circumstances (time of the day, logged in user, admin privileges etc.), different Javascript alert boxes can popup. How can I handle something like that? In other words, how can I handle an alert/confirm box which does not exist all the time??

The best approach will be to check the contents of the alert/confirm box and decide which button to click.

Please help,

Mar 27, 2014 at 2:01 PM
Without knowing more, something like this may work
            var test = new CUITe_BrowserDialog();

            if (test.Exists) 
                if (test.BoundingRectangle.X > 0)
                    test.PerformDialogAction(BrowserDialogAction.Yes); //or whatever other action you would like to perform
                TestContext.WriteLine("Dialog exists but not visible on-screen");
                TestContext.WriteLine("Dialog does not exist but not visible on-screen");
Marked as answer by Ksaxena on 4/1/2014 at 12:30 PM
Dec 16, 2014 at 9:23 PM

I am having the similar problem, in my webpage i get an alert message, but it is not a browser dialog it is a message window on a webpage, how should i handle that?