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

Unexpected dialog encountered. Closing the dialog, and halting execution

3 Answers 256 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
test cdb
Top achievements
Rank 1
test cdb asked on 16 Jul 2010, 11:48 AM

Hello,

I have downloaded the last WEBAII framework (WebAii_Testing_Framework_2010_2_713_FREE_EDITION.msi) and this framework do not behave the same way as the previous one. During the exact same test (no code modification, only the framework update)  I obtain now : 16/07/2010 12:29:11.374 ' - Unexpected dialog encountered. Closing the dialog, and halting execution.

 

It appears when a the IE8 Win32 OpenDialog is displayed (French System so, the title is Ouvrir and so on).

I have tried "manager.DialogMonitor.Stop" but, same error, it closes the dialog directly with this error.

Is there a way to indicate the framework to not monitor this window? It is because I manage this type of window using an external executable to manipulate the different OpenDialog by language.

Thanks & Regards.

-----------------

I have found a way that suit my need at the moment: "mySettings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle"

Regards.

3 Answers, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 19 Jul 2010, 07:47 PM
Hello test cdb,

I am glad you found the right solution. I was just about to suggest the settings object which you found on your own.

Greetings,
Cody
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Saket
Top achievements
Rank 1
answered on 23 Jan 2012, 07:08 AM
Hi,

On the same lines, i have my custom dilog handler for unexpected dilaog defined as
Manager.DialogMonitor.Start();
           
            for (int dialog = 0; dialog < Manager.DialogMonitor.Dialogs.Count; dialog++)
            {
            
                Manager.DialogMonitor.Dialogs[dialog].HandlerDelegate = CatchMessage;
               
            }
            Manager.DialogMonitor.AddDialog(AlertDialog.CreateAlertDialog(Manager.ActiveBrowser, DialogButton.OK));
            Manager.DialogMonitor.Stop();
            UnexpectedDialogAction action = UnexpectedDialogAction.HandleAndFailTest;

here i am expecting that if any unexpected javascript occurs it should call the CatchMessage block of code and fail the test however it goes ahead and executes all the other steps in the test gives a result as Passed along with thw message "Unexpected dialog occured..."
Anu clue where i am wrong or how to proceed..

To note : i am using the same ideology while i am performing an action, i.e on save of a form if the madatory feild is not filled system prompts with an dilaog which is being handled as expected.The above problem occurs in case of page load
help appreciated

Thanks
0
Stoich
Telerik team
answered on 26 Jan 2012, 04:37 PM
Hi Saket,
it seems to me that your code has two problems:
One is that you stop the Dialog monitor
Manager.DialogMonitor.Stop();
this simply means to Dialogs can be handled. If you need to stop it, do it at the end of the test.
In any case, you shouldn't need additional code if UnexpectedDialogAction is correctly set.

Instead of setting UnexpectedDialogAction action = UnexpectedDialogAction.HandleAndFailTest; in code, try setting it from the TestList settings file:
http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/test-execution/test-list-settings.aspx

Another way would be to actually handle the Javascript error and force the test to throw an exception:
public class FailOnAlert : BaseWebAiiTest
   {
       #region [ Dynamic Pages Reference ]
 
       private Pages _pages;
 
       /// <summary>
       /// Gets the Pages object that has references
       /// to all the elements, frames or regions
       /// in this project.
       /// </summary>
       public Pages Pages
       {
           get
           {
               if (_pages == null)
               {
                   _pages = new Pages(Manager.Current);
               }
               return _pages;
           }
       }
 
       #endregion
        
       // Add your test methods here...
    
       private AlertDialog _dialog;
        
       [CodedStep(@"Initialize Dialog")]
       public void FailOnAlert_CodedStep()
       {
           //Create dialog
           _dialog = AlertDialog.CreateAlertDialog(Manager.ActiveBrowser, DialogButton.OK);
 
           //Add dialog to dialog monitor
           Manager.DialogMonitor.AddDialog(_dialog);
       }
    
       [CodedStep(@"Clean up and check")]
       public void FailOnAlert_CodedStep1()
       {
           //Give dialog monitor some time to handle the dialog (if one occurs)
           System.Threading.Thread.Sleep(1000);
            
           //Check the dialog state
           if (_dialog.CurrentState == DialogCurrentState.Handled)
           {
               throw new Exception("This is not expected");
           }
       }
   }

Regards,
Stoich
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
test cdb
Top achievements
Rank 1
Answers by
Cody
Telerik team
Saket
Top achievements
Rank 1
Stoich
Telerik team
Share this question
or