The Alert dialog is getting closed immediately before doing any operation on it in WebAii

7 posts, 0 answers
  1. Hemashree
    Hemashree avatar
    9 posts
    Member since:
    Jul 2012

    Posted 08 Dec 2010 Link to this post

    Hi,

    I am trying to open one Alert dialog and do some operation on it using webAii automation.The scenario is like this:

    1.I want to delete a record.So I am selecting one record

    2.Clicking on Remove selecetd record button.Onclick of this I am getting one Alert dialog.

    3.After clicking on this button the Alert pop up is coming  and it is getting closed before the test script goes to next line

    4.I am not able to capture the dialog in Dialog monitor

    Please help me on this.

  2. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 08 Dec 2010 Link to this post

    Hi Hemashree,

    What may be happening is our "Unexpected Dialog Handler" feature is getting in the way. Try turning it off using this line of code at the beginning of your test:

    Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;

    Greetings,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
  3. Hemashree
    Hemashree avatar
    9 posts
    Member since:
    Jul 2012

    Posted 09 Dec 2010 Link to this post

    Hi,

    Thanks a lot for your reply.....
    Now what is happening is the Alert dialog which is opened is not getting closed immediately but still it is not going to the next line of code.It will be there in that same line of test and the status will be Processing only in the Browser.

    Please help me to resolve this.

    Thanks,
    Hemashree
  4. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 09 Dec 2010 Link to this post

    Hi Hemashree,

    I need to see a screenshot of this alert dialog along with your test code. Once you post that I will study it to try and determine why it's not working as expected.

    Kind regards,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
  5. Hemashree
    Hemashree avatar
    9 posts
    Member since:
    Jul 2012

    Posted 13 Dec 2010 Link to this post

    Hi,

    Thanks for the reply.

    The code looks like this:
      Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
                    Log.WriteLine(Find.ById<HtmlInputCheckBox>("ScheduleList_ctl00_ctl04_ScheduleSelectSelectCheckBox").Value);
                   //Click on RemoveSelected button
                    Find.ById<HtmlInputSubmit>("delete2").Click();
                  //Handle Alert Dialog
                    Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
                    AlertDialog altDlg = new AlertDialog(ActiveBrowser, DialogButton.OK);
                    Manager.DialogMonitor.AddDialog(altDlg);
                    Manager.DialogMonitor.Start();
                    //altDlg.WaitUntilHandled(1000);
                    Manager.DialogMonitor.RemoveDialog(altDlg);


  6. Hemashree
    Hemashree avatar
    9 posts
    Member since:
    Jul 2012

    Posted 15 Dec 2010 Link to this post

    Hi,


    Please help me to resolve the below issue as I am I need the solution immediately....

    -Thanks,
    Hemashree
  7. Cody
    Admin
    Cody avatar
    3354 posts

    Posted 15 Dec 2010 Link to this post

    Hello Hemashree,

    Thank you for that additional information. I think I see what the problem is. You need to setup your dialog handler before you click on the button that causes the alert to open. The dialog handler only watches for new dialogs after the object has been created. It will ignore dialogs that already are present at the time you create your dialog handler.

    Please try this code instead:

    Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
     
    Log.WriteLine(Find.ById<HtmlInputCheckBox>("ScheduleList_ctl00_ctl04_ScheduleSelectSelectCheckBox").Value);
     
    //Setup Alert Dialog Handler
    AlertDialog altDlg = new AlertDialog(ActiveBrowser, DialogButton.OK);
    Manager.DialogMonitor.AddDialog(altDlg);
    Manager.DialogMonitor.Start();
     
    //Click on RemoveSelected button
    Find.ById<HtmlInputSubmit>("delete2").Click();
     
    // Wait until the dialog has been handled
    altDlg.WaitUntilHandled(1000);
    Manager.DialogMonitor.RemoveDialog(altDlg);

    All the best,
    Cody
    the Telerik team
    Interested in Agile Testing? Check out Telerik TV for a recording of Automated Testing in the Agile Environment
Back to Top