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

MessageBox Automation code for silverlight

5 Answers 110 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kiran
Top achievements
Rank 2
Kiran asked on 24 Jun 2010, 11:27 PM
Hi,

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

Thanks in advance

5 Answers, 1 is accepted

Sort by
0
Missing User
answered on 29 Jun 2010, 08:56 PM
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
0
Kiran
Top achievements
Rank 2
answered on 30 Jun 2010, 10:35 AM
Hi Nelson,

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

Thanks
Kiran
0
Missing User
answered on 30 Jun 2010, 11:42 PM
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
0
Prashant
Top achievements
Rank 1
answered on 10 Feb 2011, 01:57 PM
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
0
Cody
Telerik team
answered on 16 Feb 2011, 07:12 PM
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
Tags
General Discussions
Asked by
Kiran
Top achievements
Rank 2
Answers by
Missing User
Kiran
Top achievements
Rank 2
Prashant
Top achievements
Rank 1
Cody
Telerik team
Share this question
or