I am still relatively new to using the Telerik Testing Framework and am still figuring some things out, but this one has puzzled me for almost a day now. I am running a scenario, using MSTest as the unit test framework and IE 8, to log a user in and then log out. Simple, right? Well, I can get the user logged in without issue, but after the browser navigates to the page after successful log in I will get an error trying to call the RadToolBar FindItemByText() method. I can access the "Log Off" button I am looking for if I use a more direct approach as displayed in my code example, but I really like the features that the RadControl wrappers provide. What I find the most confusing about this, is if I find the RadToolBar element (common control on the Master page for the project) and perform a FindItemByText() method prior to logging in it works without getting the error.
Thanks for any help!
The following is my code and then the details of the error captured by VS2012 debugger.
ArtOfTest.WebAii.Exceptions.ExecuteCommandException was unhandled by user code
HResult=-2146233088
Message=ExecuteCommand failed!
InError set by the client. Client Error:
System.InvalidOperationException: Javascript call [$find(\'ctl00_RadToolBarMain\')._extractItemFromDomElement(document.getElementsByTagName(\'li\')[4]).get_text()] failed! Please make sure the function exists and the call is using the correct prototype signature. Javascript error: [object Error]
at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval, Boolean returnJSON)
at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)
BrowserCommand (Type:'Action',Info:'NotSet',Action:'InvokeJsFunction',Target:'ElementId (tagName: '',occurrenceIndex: '-1')',Data:'$find(\'ctl00_RadToolBarMain\')._extractItemFromDomElement(document.getElementsByTagName(\'li\')[4]).get_text()',ClientId:'Client_ba0bd6af-47e6-4b89-90cf-184e1a3a05df',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'-1',InError:'True',Response:'System.InvalidOperationException: Javascript call [$find(\'ctl00_RadToolBarMain\')._extractItemFromDomElement(document.getElementsByTagName(\'li\')[4]).get_text()] failed! Please make sure the function exists and the call is using the correct prototype signature. Javascript error: [object Error]
at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval, Boolean returnJSON)
at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)')
InnerException: none.
Source=ArtOfTest.WebAii
StackTrace:
at ArtOfTest.WebAii.Core.Browser.ExecuteCommandInternal(BrowserCommand request)
at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request, Boolean performDomRefresh, Boolean waitUntilReady)
at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request)
at ArtOfTest.WebAii.Core.Actions.InvokeScript(String script)
at ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions.InvokeScript(String script)
at ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl.GetValue[T](String propertyName, T defaultValue)
at ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl.GetValue[T](String propertyName)
at ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl.CallMethod[T](String methodCall)
at Telerik.WebAii.Controls.Html.RadToolBarItem.get_Text()
at Telerik.WebAii.Controls.Html.RadToolBar.<>c__DisplayClass1.<FindItemByText>b__0(RadToolBarItem item)
at ArtOfTest.WebAii.Core.Find.ByCustomInternal[TControl](Predicate`1 predicate, Element e)
at ArtOfTest.WebAii.Core.Find.ByCustomInternal[TControl](Predicate`1 predicate, Element e)
at ArtOfTest.WebAii.Core.Find.ByCustomInternal[TControl](Predicate`1 predicate, Element e)
at ArtOfTest.WebAii.Core.Find.ByCustomInternal[TControl](Predicate`1 predicate, Element e)
at ArtOfTest.WebAii.Core.Find.ByCustomInternal[TControl](Predicate`1 predicate, Element e)
at ArtOfTest.WebAii.Core.Find.ByCustomInternal[TControl](Predicate`1 predicate, Element e)
at ArtOfTest.WebAii.Core.Find.ByCustom[TControl](Predicate`1 predicate)
at Telerik.WebAii.Controls.Html.RadToolBar.FindItem(Predicate`1 predicate)
at Telerik.WebAii.Controls.Html.RadToolBar.FindItemByText(String itemText)
at ALPS.Test.GuiTests.User.LoginPageTests.UsersCanSuccessfullyLogIn() in c:\DOTNETDevelopment\Test\Automation\ALPS.Test.GuiTests\User\LoginPageTests.cs:line 102
InnerException:
Thanks for any help!
The following is my code and then the details of the error captured by VS2012 debugger.
string
userName = TestContext.DataRow[
"Username"
].ToString();
ActiveBrowser.NavigateTo(
"~/User/LogInPage.aspx"
);
HtmlFindExpression untbExpr =
new
HtmlFindExpression(
"id=?RadTextBoxUserName_wrapper"
);
ActiveBrowser.WaitForElement(untbExpr, 30000,
false
);
RadTextBox usernameTb = ActiveBrowser.Find.ByExpression<RadTextBox>(untbExpr);
usernameTb.Clear();
usernameTb.TypeText(userName);
HtmlFindExpression lbExpr =
new
HtmlFindExpression(
"id=?RadButtonLogin_input"
);
ActiveBrowser.WaitForElement(lbExpr, 30000,
false
);
RadButton loginButton = ActiveBrowser.Find.ByExpression<RadButton>(lbExpr);
loginButton.MouseClick();
//Navigates to ~/Default.aspx but authenticated.
//Throws error
HtmlFindExpression expr =
new
HtmlFindExpression(
"id=?RadToolBarMain"
);
ActiveBrowser.WaitForElement(expr, 30000,
false
);
RadToolBar tb = ActiveBrowser.Find.ByExpression<RadToolBar>(expr);
RadToolBarItem lob = tb.FindItemByText(
"Log Off"
);
//WORKS!!!
//HtmlFindExpression loButton = new HtmlFindExpression("title=^Log Off", "class=rtbWrap");
//ActiveBrowser.WaitForElement(loButton, 30000, false);
//HtmlAnchor lob = ActiveBrowser.Find.ByExpression<HtmlAnchor>(loButton);
//lob.MouseHover();
ArtOfTest.WebAii.Exceptions.ExecuteCommandException was unhandled by user code
HResult=-2146233088
Message=ExecuteCommand failed!
InError set by the client. Client Error:
System.InvalidOperationException: Javascript call [$find(\'ctl00_RadToolBarMain\')._extractItemFromDomElement(document.getElementsByTagName(\'li\')[4]).get_text()] failed! Please make sure the function exists and the call is using the correct prototype signature. Javascript error: [object Error]
at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval, Boolean returnJSON)
at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)
BrowserCommand (Type:'Action',Info:'NotSet',Action:'InvokeJsFunction',Target:'ElementId (tagName: '',occurrenceIndex: '-1')',Data:'$find(\'ctl00_RadToolBarMain\')._extractItemFromDomElement(document.getElementsByTagName(\'li\')[4]).get_text()',ClientId:'Client_ba0bd6af-47e6-4b89-90cf-184e1a3a05df',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'-1',InError:'True',Response:'System.InvalidOperationException: Javascript call [$find(\'ctl00_RadToolBarMain\')._extractItemFromDomElement(document.getElementsByTagName(\'li\')[4]).get_text()] failed! Please make sure the function exists and the call is using the correct prototype signature. Javascript error: [object Error]
at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval, Boolean returnJSON)
at ArtOfTest.InternetExplorer.IECommandProcessor.InvokeFunction(String functionCall, Boolean useEval)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request)
at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommand(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)')
InnerException: none.
Source=ArtOfTest.WebAii
StackTrace:
at ArtOfTest.WebAii.Core.Browser.ExecuteCommandInternal(BrowserCommand request)
at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request, Boolean performDomRefresh, Boolean waitUntilReady)
at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request)
at ArtOfTest.WebAii.Core.Actions.InvokeScript(String script)
at ArtOfTest.WebAii.BrowserSpecialized.InternetExplorer.InternetExplorerActions.InvokeScript(String script)
at ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl.GetValue[T](String propertyName, T defaultValue)
at ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl.GetValue[T](String propertyName)
at ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl.CallMethod[T](String methodCall)
at Telerik.WebAii.Controls.Html.RadToolBarItem.get_Text()
at Telerik.WebAii.Controls.Html.RadToolBar.<>c__DisplayClass1.<FindItemByText>b__0(RadToolBarItem item)
at ArtOfTest.WebAii.Core.Find.ByCustomInternal[TControl](Predicate`1 predicate, Element e)
at ArtOfTest.WebAii.Core.Find.ByCustomInternal[TControl](Predicate`1 predicate, Element e)
at ArtOfTest.WebAii.Core.Find.ByCustomInternal[TControl](Predicate`1 predicate, Element e)
at ArtOfTest.WebAii.Core.Find.ByCustomInternal[TControl](Predicate`1 predicate, Element e)
at ArtOfTest.WebAii.Core.Find.ByCustomInternal[TControl](Predicate`1 predicate, Element e)
at ArtOfTest.WebAii.Core.Find.ByCustomInternal[TControl](Predicate`1 predicate, Element e)
at ArtOfTest.WebAii.Core.Find.ByCustom[TControl](Predicate`1 predicate)
at Telerik.WebAii.Controls.Html.RadToolBar.FindItem(Predicate`1 predicate)
at Telerik.WebAii.Controls.Html.RadToolBar.FindItemByText(String itemText)
at ALPS.Test.GuiTests.User.LoginPageTests.UsersCanSuccessfullyLogIn() in c:\DOTNETDevelopment\Test\Automation\ALPS.Test.GuiTests\User\LoginPageTests.cs:line 102
InnerException: