This is a migrated thread and some comments may be shown as answers.

Tests are not handling Confirm dialogs when using "UnexpectedDialogAction"

4 Answers 252 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Steve909
Top achievements
Rank 2
Steve909 asked on 22 Oct 2011, 01:10 AM
The had problems running automated tests with Confirm or Alert dialogs in my application. So I used Settings

Current UnexpectedDialogAction = UnexpectedDialogAction HandleAndContinue in one of the test steps that may or may not have a alert dialog. If a dialog is present the dialog handler will CLOSE the dialog window (NOT click the OK button). That was acceptable. However, in later STEPS I use the "Handle 'Confirm' dialog" step because I know I need to actually press OK in the Confirm dialogs. etc. These "Handle 'Confirm' dialog" steps does not work (the dialog window is CLOSED only) when I run the tests in a TEST LIST. However, if I run one-by-one the dialog window OK button is clicked correctly at the "Handle 'Confirm' dialog" step.

Can I either modify how the confirm/alert dialogs will handle the "UnexectedDialogAction" i.e. "CLOSE" or click the "OK" button? or STOP the "UnexpectedDialogAction at ONE test step ONLY not all steps in a Test-List?

Thanks.

 

4 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 24 Oct 2011, 12:18 PM
Hello Stephen Cannon,

You can manually set the UnexpectedDialogAction behavior with code like this:
Settings.Current.UnexpectedDialogAction = UnexpectedDialogAction.HandleAndContinue;
Just put this code in a Coded step and place it before the step where you expect the alert dialog to appear. 

Now, you can change it again for the step where you want to handle the dialog by putting another Coded step with the following code:
Settings.Current.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
Note that, setting the UnxpectedDialogAction in this way will also work even if you run your test from Quick Execution.   

Hope this helps!

Best wishes,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Steve909
Top achievements
Rank 2
answered on 25 Oct 2011, 05:35 PM
Hi Plamen,

The solution did not work. The UnExpectedDialogAction.DoNotHandle stmt causes any "Handle Alert Dialog" or "Handle Confirm Dialog" stmts/steps in the test to stop working. However, it does work for that particular step above. The test fails on the next "Handle" stmt./step. So I can't use these stmts. Any other suggestions?

Can the "UnexpectedDialogAction.HandleAndContinue" stmt do anything except CLOSE the Dialog Box? It would be nice if it could click the "OK" button. That would solve my problem.

Thanks,

Stephen Cannon
0
Steve909
Top achievements
Rank 2
answered on 27 Oct 2011, 10:26 PM
Hi Plamen,

I did not hear back from you yet. I looks like the problem is solved. The following code was added to my test step
to direct the Dialog Monitor to "Handle" the alert dialog by the "OK" button and NOT to "CLOSE" the dialog.

            Manager.DialogMonitor.AddDialog(AlertDialog.CreateAlertDialog(ActiveBrowser, DialogButton.OK));
            Manager.DialogMonitor.Start();

Thanks,

Stephen Cannon
0
Plamen
Telerik team
answered on 28 Oct 2011, 07:37 AM
Hi Steve909,

My apologies for the delay responding to you. I'm glad to hear you've managed resolve the issue. Just in case you haven't done so already, you can also check out our online documentation section on "Build-in Dialog Handlers" here.  

Best wishes,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Steve909
Top achievements
Rank 2
Answers by
Plamen
Telerik team
Steve909
Top achievements
Rank 2
Share this question
or