I am hoping you can help with me a couple of issues related to verification of HTML documents.
I am using TestStudio 2011.1.829.0 in a TFS-based test environment. The application being tested is a Silverlight web application.
I am writing a test for an application feature that does the following: User specifies parameters and invokes a command which results in an HTML document being generated dynamically and displayed in a window inside the application. The window is a custom class derived from System.Windows.Controls.ContentControl. It shows up in the DOM of the Silverlight application and I am able to detect that it is displayed.
Here are the issues that I am trying to resolve:
a) HTML document generation takes a while and so there is a delay between the window displaying and the document displaying inside it. So the test needs to wait until the page is loaded in the window and then verify that the correct document was loaded by verifying some of its content. I am trying to find a reliable way to detect that the document has been fully loaded and being displayed in the window - I am trying to do this by trying to detect the existence of specific text strings in the document.
b) The test needs to run against multiple test environments on which the application is deployed - each of these environments has a different URL which don't have anything in common between them. Here are a few examples: http://server1:10/
. So the wait and verification statements cannot be dependent on the environment on which it was recorded.
I have tried the following:
a) Directly recording a wait statement based on a field inside the HTML document. This works if the test runs against the environment in which it was recorded - but does not work on other environments (test fails on the wait statement). This is unlike statements recorded with Silverlight controls - which can be recorded on one environment but work on all environments.
b) Coded steps using the HtmlWait class. The following code shows what I have tried - the Find for "form1" returns a valid value but the other two Find statements return null resulting in an unhandled exception on the next statement.
CodedStep(@"Wait for Exists 'PatientTableCell'")]
public void LoginAsAdministratorAndPreviewReport_CodedStep()
HtmlForm ReportViewerForm = Find.ById<HtmlForm>("form1");
HtmlDiv div = Find.ByName<HtmlDiv>("MainReportViewer_ReportViewer?");
HtmlWait waitObj = div.Wait;
HtmlTable ReportViewerOuterTable = Find.ByTagIndex<HtmlTable>("table", 0);
//HtmlTableCell patientTableCell = ReportViewerForm.Find.ByContent<HtmlTableCell>("Patient Demographic");
//// Wait for Exists 'PatientTableCell'
Any suggestions on how I can accomplish what I need? Let me know if you need further information.