Hello,
I have a couple of issues I'm currently wresting with.
To start, I'm writing "code only" tests - I only have access to the API, not the full Test Studio. So please, code-only responses.
I have a Silverlight application. It consists of many individual pages with Silverlight (and custom and 3rd party) controls on them. I'm writing a "smoke test" that just iterates through the pages of the application (each URI is kept in the database. In my test I open a connection to the database, read the URI column from the Menu table, construct the full path to the resource and use ActiveBrowser.navigateTo(URI) to go to that page) - the issue is twofold:
If a page has an exception on it (which is what I'm testing for - pages that throw exceptions when you attempt to load them) it will bring up a dialog box with the exception info on it. How do I capture that dialog and retrieve information from it? It's hard to explain the exact nature of this dialog box - it's not a custom dialog box that we wrote, it's just the 'generic' Silverlight "Error Occured" dialog box which has the exception and a 'drop down button' which, when clicked, opens up a text area with the full exception description on it. Another way of looking at it is: I want to trap (or list or write to Console) every page that throws this type of dialog so I know when pages fail to load (or throw an exception) in my app. Like I said, this is a "smoke test" that simply loads each page in our application and makes sure there are no exceptions encountered. When I do encounter an exception, how do I "mark" it as such or extract information from it?
The second part of the question also has to do with dialog boxes - this time, we have certain pages that, when you navigate to them, the first thing they do is bring up a modal dialog box (actually it's just a control, not of type Modal Dialog box or anything) - basically it can be thought of as just a Modal Silverlight window that is brought up upon page load - I know which pages do this (they all have a certain string present in their URI which I can code for in the test and have already done so) and can attach an event handler or something upon encountering one... but the code I copped from your web site doesn't quite work for me:
I have connived this into my code but not sure what I've done is correct - I also had to change the return type of the Delegate to be "void" as the compiler complained that the method had the wrong return type. I just commented out the return statements.
Any help is appreciated as always.
Thanks,
Jess
I have a couple of issues I'm currently wresting with.
To start, I'm writing "code only" tests - I only have access to the API, not the full Test Studio. So please, code-only responses.
I have a Silverlight application. It consists of many individual pages with Silverlight (and custom and 3rd party) controls on them. I'm writing a "smoke test" that just iterates through the pages of the application (each URI is kept in the database. In my test I open a connection to the database, read the URI column from the Menu table, construct the full path to the resource and use ActiveBrowser.navigateTo(URI) to go to that page) - the issue is twofold:
If a page has an exception on it (which is what I'm testing for - pages that throw exceptions when you attempt to load them) it will bring up a dialog box with the exception info on it. How do I capture that dialog and retrieve information from it? It's hard to explain the exact nature of this dialog box - it's not a custom dialog box that we wrote, it's just the 'generic' Silverlight "Error Occured" dialog box which has the exception and a 'drop down button' which, when clicked, opens up a text area with the full exception description on it. Another way of looking at it is: I want to trap (or list or write to Console) every page that throws this type of dialog so I know when pages fail to load (or throw an exception) in my app. Like I said, this is a "smoke test" that simply loads each page in our application and makes sure there are no exceptions encountered. When I do encounter an exception, how do I "mark" it as such or extract information from it?
The second part of the question also has to do with dialog boxes - this time, we have certain pages that, when you navigate to them, the first thing they do is bring up a modal dialog box (actually it's just a control, not of type Modal Dialog box or anything) - basically it can be thought of as just a Modal Silverlight window that is brought up upon page load - I know which pages do this (they all have a certain string present in their URI which I can code for in the test and have already done so) and can attach an event handler or something upon encountering one... but the code I copped from your web site doesn't quite work for me:
public void DoCustomDialogHandlingForBuiltInDialogs()
{
AlertDialog myAlertDialog = new AlertDialog(ActiveBrowser, DialogButton.OK);
myAlertDialog.HandlerDelegate = new DialogHandlerDelegate(MyCustomAlertHandler);
// Add dialog to monitor and start monitoring
Manager.DialogMonitor.AddDialog(myAlertDialog);
Manager.DialogMonitor.Start();
Actions.InvokeScript("InvokeAlert()");
}
///<
summary
>
/// Custom dialog handler delegate
///</
summary
>
///<
param
name
=
"dialog"
>The dialog to handle</
param
>
///<
returns
></
returns
>
public bool MyCustomAlertHandler(IDialog dialog)
{
// Simply close the dialog
dialog.Window.Close();
try
{
// Wait until it is closed
dialog.Window.WaitForVisibility(false, 50);
Log.WriteLine("Alert Handled!");
return true;
}
catch
{
Log.WriteLine("Failed to handle alert!");
// return false if the dialog did not close as expected
return false;
}
}
I have connived this into my code but not sure what I've done is correct - I also had to change the return type of the Delegate to be "void" as the compiler complained that the method had the wrong return type. I just commented out the return statements.
Any help is appreciated as always.
Thanks,
Jess