Lately I needed to focus on some other stuff in our project so I couldn't proceed with your test code.
Now that I tried it and found that It still doesnot work as it is trying to execute the script in the testFrame context and eventually ends up with the following JS exception:
Error in Test 'UserManagementTests.SignInAndSignOut'
Exception was thrown by the client engine: "[TestExecutorException]: Unhandled JS exception while executing command handler function ExecuteScript. (Details: {\"name\":\"TypeError\",\"message\":\"Object
doesn't support this property or method\",\"number\":-2146827850,\"description\":\"Object doesn't support this property or method\"})" when running command: ExecuteScript on the target: < id=, index: 0>.
Exception Details:
Microsoft.Web.Testing.Light.WebTestException: Exception was thrown by the client engine: "[TestExecutorException]: Unhandled JS exception while executing command handler function ExecuteScript. (Details: {\"name\":\"TypeError\",\"message\":\"Object doesn't
support this property or method\",\"number\":-2146827850,\"description\":\"Object doesn't support this property or method\"})" when running command: ExecuteScript on the target: < id=, index: 0>.
Source Error:
Line 14:
Line 15: // execute a script that opens a new window that loads your real site
Line 16: page.ExecuteScript("function openWindow() { window.open('Login.aspx'); return true;} openWindow();");
Line 17:
Line 18: // get the popupwindow and automate against it.
[Microsoft.Web.Testing.Light.WebTestException: Exception was thrown by the client engine: "[TestExecutorException]: Unhandled JS exception while executing command handler function ExecuteScript. (Details: {\"name\":\"TypeError\",\"message\":\"Object doesn't support this property or method\",\"number\":-2146827850,\"description\":\"Object doesn't support this property or method\"})" when running command: ExecuteScript on the target: < id=, index: 0>.]
at Microsoft.Web.Testing.Light.HtmlPage.ExecuteCommand(BrowserCommand command) in C:\Users\mosborn.000\Desktop\Microsoft.Web.Testing.Lightweight\Framework\UI\HtmlPage.cs:line 110
at Microsoft.Web.Testing.Light.HtmlPage.ExecuteScript(String scriptExpression) in C:\Users\mosborn.000\Desktop\Microsoft.Web.Testing.Lightweight\Framework\UI\HtmlPage.cs:line 207
at UserManagementTests.SignInAndSignOut() in c:\v5\Www\UI\App_Code\Tests\UserManagementTests.cs:line 16
Version Information: Microsoft .NET Framework Version: 2.0.50727.3082; ASP.NET Version: 2.0.50727.4005; ASP.NET AJAX Version: 3.5.30729.196; Microsoft.Web.Testing Version: 1.0.0.0</div>
My web test method looks like as below:
[
WebTestMethod]
public
void SignInAndSignOut()
{
// Navigate to the login page
HtmlPage page =
new
HtmlPage("TrueBlank.aspx");
// execute a script that opens a new window that loads your real site
page.ExecuteScript("function openWindow() { window.open('Login.aspx'); return true;} openWindow();");
// get the popupwindow and automate against it.
HtmlPage newPage = page.GetPopupWindow(1);
// Fill Login control user/password and click login button
page.Elements.Find("UserName").SetText("UItestUser");
page.Elements.Find(
"Password").SetText("password");
page.Elements.Find("butLogin").Click(WaitFor.Postback);
// Verify content of the Home page
Assert.AreEqual("Application Home Page",
page.Elements.Find("slblApplicationHomePage").GetInnerText());
// Click the logout link
page.Elements.Find("shlLogout").Click(WaitFor.Postback);
// Verify login button now exists.
Assert.IsTrue(page.Elements.Exists("butLogin"));
}
I traced back to the LTAF code where it was failing:
evalInActiveFrame : function(expression) {
// Frame containing the running test (where the script must be evaluated)
var frame = TestExecutor.get_activeWindow().get_activeFrame().get_jsFrame();
// Safari doesn't support changing the context of the eval function,
// so it has to be done specially
if ("safari" != DomSupport.get_navigatorName())
{
return frame.eval(expression); //IT FAILS AT THIS LINE
}
.
.
.
}
Can you provide some other insight?
Besides this, yes, it would be of great help if we can run the tests in new windows. Also, currently, test running frames can be used to display outputs/exceptions/logs etc instead.
FRMJiggs
Member
4 Points
5 Posts
Re: Using LTAF to automate a page with frames.
Apr 28, 2009 05:55 PM|LINK
Hi Federico,
Lately I needed to focus on some other stuff in our project so I couldn't proceed with your test code.
Now that I tried it and found that It still doesnot work as it is trying to execute the script in the testFrame context and eventually ends up with the following JS exception:
Test Stack Trace:
<div style="BACKGROUND-COLOR: white; WIDTH: 100%; FONT-FAMILY: 'Verdana'; COLOR: black; FONT-SIZE: 8.5pt">Error in Test 'UserManagementTests.SignInAndSignOut'
Exception was thrown by the client engine: "[TestExecutorException]: Unhandled JS exception while executing command handler function ExecuteScript. (Details: {\"name\":\"TypeError\",\"message\":\"Object doesn't support this property or method\",\"number\":-2146827850,\"description\":\"Object doesn't support this property or method\"})" when running command: ExecuteScript on the target: < id=, index: 0>.
Exception Details: Microsoft.Web.Testing.Light.WebTestException: Exception was thrown by the client engine: "[TestExecutorException]: Unhandled JS exception while executing command handler function ExecuteScript. (Details: {\"name\":\"TypeError\",\"message\":\"Object doesn't support this property or method\",\"number\":-2146827850,\"description\":\"Object doesn't support this property or method\"})" when running command: ExecuteScript on the target: < id=, index: 0>.Source Error:
Line 14: Line 15: // execute a script that opens a new window that loads your real site Line 16: page.ExecuteScript("function openWindow() { window.open('Login.aspx'); return true;} openWindow();"); Line 17: Line 18: // get the popupwindow and automate against it.Source File: c:\v5\Www\UI\App_Code\Tests\UserManagementTests.cs Line: 16 Method: UserManagementTests.SignInAndSignOut()
Stack Trace:
Version Information: Microsoft .NET Framework Version: 2.0.50727.3082; ASP.NET Version: 2.0.50727.4005; ASP.NET AJAX Version: 3.5.30729.196; Microsoft.Web.Testing Version: 1.0.0.0</div>
My web test method looks like as below:
[
WebTestMethod] public void SignInAndSignOut(){
// Navigate to the login page HtmlPage page = new HtmlPage("TrueBlank.aspx"); // execute a script that opens a new window that loads your real site page.ExecuteScript("function openWindow() { window.open('Login.aspx'); return true;} openWindow();");
// get the popupwindow and automate against it. HtmlPage newPage = page.GetPopupWindow(1);
// Fill Login control user/password and click login button page.Elements.Find("UserName").SetText("UItestUser");page.Elements.Find(
"Password").SetText("password"); page.Elements.Find("butLogin").Click(WaitFor.Postback); // Verify content of the Home page Assert.AreEqual("Application Home Page", page.Elements.Find("slblApplicationHomePage").GetInnerText()); // Click the logout link page.Elements.Find("shlLogout").Click(WaitFor.Postback); // Verify login button now exists. Assert.IsTrue(page.Elements.Exists("butLogin"));}
I traced back to the LTAF code where it was failing:
Can you provide some other insight?
Besides this, yes, it would be of great help if we can run the tests in new windows. Also, currently, test running frames can be used to display outputs/exceptions/logs etc instead.
Waiting for your response...
- Jignesh