Tests are not handling Confirm dialogs when using "UnexpectedDialogAction"

5 posts, 0 answers
  1. Steve909
    Steve909 avatar
    1 posts
    Member since:
    Nov 2009

    Posted 21 Oct 2011 Link to this post

    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.

     

  2. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 24 Oct 2011 Link to this post

    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.
  3. Steve909
    Steve909 avatar
    1 posts
    Member since:
    Nov 2009

    Posted 25 Oct 2011 Link to this post

    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
  4. Steve909
    Steve909 avatar
    1 posts
    Member since:
    Nov 2009

    Posted 27 Oct 2011 Link to this post

    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
  5. Plamen
    Admin
    Plamen avatar
    8 posts

    Posted 28 Oct 2011 Link to this post

    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.
Back to Top
  Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!