Skip Navigation LinksHome / Community / Forums / Test Studio Express (Visual Studio plugin): Telerik Testing Framework > Telerik can't handle more than 1 dialogs in Silverlight

Not answered Telerik can't handle more than 1 dialogs in Silverlight

Feed from this thread
  • Tuan avatar

    Posted on May 14, 2012 (permalink)

    Hi telerik,

    I'm automation an Silverlight app that invoke a dialogs that looks like windows dialog (see attach image)

    So I used this code and it works but when it handle the second dialog, it just stop there and it doesn't click the OK button.
    Please help me figure this out.
    Thanks

    try
    {
        Button btnRemoveDashboard = GlobalObject.SILVERLIGHTAPP.Find.ByName<Button>("btnRemoveDashboard");
        GlobalObject.MANAGER.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
     
        GenericDialog altDlg = new GenericDialog(SM2Utilities.GlobalObject.BROWSER, "Close" + strDBName, true, "OK", "Are you sure you want to remove this dashboard and all of its panels?");
        altDlg.HandlerDelegate = MyCustomAlertHandler;
        altDlg.DismissButton = DialogButton.OK;
        GlobalObject.MANAGER.DialogMonitor.AddDialog(altDlg);
        GlobalObject.MANAGER.DialogMonitor.Start();
        btnRemoveDashboard.User.Click();
     
        altDlg.WaitUntilHandled(5000);
     
        GlobalObject.MANAGER.DialogMonitor.RemoveDialog(altDlg);
        GlobalObject.MANAGER.DialogMonitor.Stop();
        GlobalObject.MANAGER.Dispose();
    }
    catch (Exception)
    {
    }
     
     
    public static void MyCustomAlertHandler(IDialog dialog)
    {
                Window okButton = WindowManager.FindWindowRecursively(dialog.Window.Handle, "OK", false, 0);
     
                GlobalObject.MANAGER.Desktop.Mouse.Click(MouseClickType.LeftClick, okButton.Rectangle);
                dialog.HandleCount++;
    }

    Attached files

    Reply

  • Anthony Anthony admin's avatar

    Posted on May 14, 2012 (permalink)

    Hello Tuan,

    Are you creating a GenericDialog and adding it to the monitor for each dialog to be handled? The following code worked for me against a public site with an Alert dialog:

    [TestMethod]
    public void TwoAlertsCustom()
    {
        Manager.Settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
        Manager.LaunchNewBrowser(BrowserType.InternetExplorer);
     
        GenericDialog ad = new GenericDialog(ActiveBrowser, "Message", true);
        ad.HandlerDelegate = MyCustomAlertHandler;
        ad.DismissButton = DialogButton.OK;
     
        GenericDialog ad2 = new GenericDialog(ActiveBrowser, "Message", true);
        ad.HandlerDelegate = MyCustomAlertHandler;
        ad.DismissButton = DialogButton.OK;
     
        Manager.DialogMonitor.AddDialog(ad);
        Manager.DialogMonitor.AddDialog(ad2);
        Manager.DialogMonitor.Start();
     
        ArtOfTest.WebAii.Core.Browser frSub = ActiveBrowser.Frames["view"];
        frSub.RefreshDomTree();
     
        HtmlInputButton show = frSub.Find.ByExpression<HtmlInputButton>("value=Show alert box");
        show.Click();
        ad.WaitUntilHandled(5000);
     
        show.Click();
        ad2.WaitUntilHandled(5000);
     
        Manager.DialogMonitor.RemoveDialog(ad);
        Manager.DialogMonitor.RemoveDialog(ad2);
        Manager.DialogMonitor.Stop();
        //Manager.Dispose();
    }
     
    public static void MyCustomAlertHandler(IDialog dialog)
    {
        Window okButton = WindowManager.FindWindowRecursively(dialog.Window.Handle, "OK", false, 0);
        Manager.Current.Desktop.Mouse.Click(MouseClickType.LeftClick, okButton.Rectangle);
        dialog.HandleCount++;
    }


    Greetings,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings

    Reply

  •   Cast Your Vote at DevPro Connections! Cast Your Vote at  Win IT Pro Connections!

Back to Top

Skip Navigation LinksHome / Community / Forums / Test Studio Express (Visual Studio plugin): Telerik Testing Framework > Telerik can't handle more than 1 dialogs in Silverlight
Related resources for "Telerik can't handle more than 1 dialogs in Silverlight"

Testing Framework Features  |  Documentation |  Videos  |  Webinars  |  Automated Testing Tools  ]