MessageBox Automation code for silverlight

6 posts, 0 answers
  1. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 24 Jun 2010 Link to this post

    Hi,

    Can anybody provide the code for identifying messagebox dialogue in silverlight?

    Thanks in advance
  2. Missing user
    Missing user avatar

    Posted 29 Jun 2010 Link to this post

    Hello kiran,

    Is there a specific messagebox dialogue controkl type you are refering to? Silverlight Child Window and Popup windows should be covered by this blog. If you can post back with an online example or documentation, I can try to see what we can try.

    Regards,
    Nelson
    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
  3. Kiran
    Kiran avatar
    56 posts
    Member since:
    Dec 2008

    Posted 30 Jun 2010 Link to this post

    Hi Nelson,

    I am taking about
    MessageBox.Show("Hello World !!!!!!!!", "Message");

    Thanks
    Kiran
  4. Missing user
    Missing user avatar

    Posted 30 Jun 2010 Link to this post

    Hello again kiran,

    Thanks for clearing that up, for Custom Win32 dialogs you can use the Generic Handlers in the WebAii Framework as described in this documentation.

    But if you are using WebUI Dev Edition recording, you can add a Generic Dialog handler from the 'Dialogs...' drop down in the Steps Tab. Please see pages 34-35 in the Dev Edition Quick Start Guide for reference.

    Sincerely,
    Nelson
    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
  5. Prashant
    Prashant avatar
    20 posts
    Member since:
    Nov 2010

    Posted 10 Feb 2011 Link to this post

    Hi Cody,

    We tried the solution that you have given and it works fine.
    But we also want to verify the error message text on message box. Can you please help us in this.

    Thanks,
    Madhav
  6. Cody
    Admin
    Cody avatar
    3360 posts

    Posted 16 Feb 2011 Link to this post

    Hi Madhav,

    Yes. Here is a complete working sample test:

    [TestMethod]
    public void VerifyAlertDialogText()
    {
        // Load our webpage in the browser
        Manager.LaunchNewBrowser();
     
        // Initialize custom 'Alert' dialog handler
        AlertDialog alertDialog = new AlertDialog(ActiveBrowser, DialogButton.OK);
        alertDialog.HandlerDelegate = MyCustomAlertHandler;
        Manager.DialogMonitor.AddDialog(alertDialog);
     
        // Click that
        ActiveBrowser.Frames["view"].RefreshDomTree();
        ActiveBrowser.Frames["view"].Find.ByExpression<HtmlInputButton>("value=Show alert box", "tagname=input").Click();
     
        // Wait Until Dialog is Handled.
        alertDialog.WaitUntilHandled(5000);
    }
     
    /// <summary>
    /// Custom alert dialog hander to read and verify the text
    /// </summary>
    /// <param name="dialog">The alert dialog to validate</param>
    public void MyCustomAlertHandler(IDialog dialog)
    {
        string txt = dialog.Window.AllChildren[dialog.Window.AllChildren.Count - 1].Caption;
        Assert.AreEqual<string>("Hello! I am an alert box!", txt);
        Log.WriteLine(txt);
     
        Window okButton = WindowManager.FindWindowRecursively(dialog.Window.Handle, "OK", false, 0);
        Manager.Desktop.Mouse.Click(MouseClickType.LeftClick, okButton.Rectangle);
        dialog.HandleCount++;
    }

    All the best,
    Cody
    the Telerik team
Back to Top