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

Multiple framework issues (xpath not found in IE, WaitForNewBrowserConnect failure, InvokeEvent failure)

2 Answers 228 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andrei
Top achievements
Rank 1
Andrei asked on 19 Feb 2013, 11:15 AM
Hello,

we've tried using Telerik WebAii framework on publicly accessed site thomsons.com and encountered multiple issues. Some of them are described below:

A lot of elements can't be found in IE by xpath (and are successfully found in Chrome):
[Test]
        public void IEIssue()
        {
            Manager.Current.ActiveBrowser.RefreshDomTree();
 
            string xpath = "//a[child::span[contains(text(), 'Enrolment Calculator')]]";
 
            var htmlFindExpression = new HtmlFindExpression(string.Format("XPath={0}", xpath));
            Manager.Current.ActiveBrowser.WaitForElement(htmlFindExpression, 10000, false);
 
            Element anchor = Manager.Current.ActiveBrowser.Find.ByXPath(xpath); // not found in IE
            anchor.As<HtmlAnchor>().Click();
        }

The following exception is thrown on "WaitForElement" line:
Exception thrown during the wait for a condition. Error: Unexpected error while waiting on condition. Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: Refresh() failed due to an unexpected exception. ---> System.ArgumentException: The empty string '' is not a valid name.
Parameter name: docTypeName
   at System.Xml.DtdParser.InitializeFreeFloatingDtd(String baseUri, String docTypeName, String publicId, String systemId, String internalSubset, IDtdParserAdapter adapter)
   at System.Xml.DtdParser.System.Xml.IDtdParser.ParseFreeFloatingDtd(String baseUri, String docTypeName, String publicId, String systemId, String internalSubset, IDtdParserAdapter adapter)
   at System.Xml.XmlLoader.ParseDocumentType(XmlDocumentType dtNode, Boolean bUseResolver, XmlResolver resolver)
   at System.Xml.XmlLoader.ParseDocumentType(XmlDocumentType dtNode)
   at System.Xml.XmlDocumentType..ctor(String name, String publicId, String systemId, String internalSubset, XmlDocument doc)
   at System.Xml.XmlDocument.CreateDocumentType(String name, String publicId, String systemId, String internalSubset)
   at System.Xml.XmlDocument.CreateNode(XmlNodeType type, String prefix, String name, String namespaceURI)
   at System.Xml.XmlDocument.CreateNode(XmlNodeType type, String name, String namespaceURI)
   at ArtOfTest.WebAii.ObjectModel.Element.BuildXml(XmlDocument doc, XmlNode parent, Element element, Boolean withAbsoluteIndex, Boolean allChildNodes, Boolean ignoreTestRegionTags)
   at ArtOfTest.WebAii.ObjectModel.Element.BuildXml(XmlDocument doc, XmlNode parent, Element element, Boolean withAbsoluteIndex, Boolean allChildNodes, Boolean ignoreTestRegionTags)
   at ArtOfTest.WebAii.ObjectModel.Element.BuildXml(XmlDocument doc, XmlNode parent, Element element, Boolean withAbsoluteIndex, Boolean allChildNodes, Boolean ignoreTestRegionTags)
   at ArtOfTest.WebAii.ObjectModel.Element.BuildXml(XmlDocument doc, XmlNode parent, Element element, Boolean withAbsoluteIndex, Boolean allChildNodes, Boolean ignoreTestRegionTags)
   at ArtOfTest.WebAii.ObjectModel.Element.BuildXml(XmlDocument doc, XmlNode parent, Element element, Boolean withAbsoluteIndex, Boolean allChildNodes, Boolean ignoreTestRegionTags)
   at ArtOfTest.WebAii.ObjectModel.Element.BuildXml(XmlDocument doc, XmlNode parent, Element element, Boolean withAbsoluteIndex, Boolean allChildNodes, Boolean ignoreTestRegionTags)
   at ArtOfTest.WebAii.ObjectModel.Element.BuildXml(XmlDocument doc, XmlNode parent, Element element, Boolean withAbsoluteIndex, Boolean allChildNodes, Boolean ignoreTestRegionTags)
   at ArtOfTest.WebAii.ObjectModel.Element.BuildXml(XmlDocument doc, XmlNode parent, Element element, Boolean withAbsoluteIndex, Boolean allChildNodes, Boolean ignoreTestRegionTags)
   at ArtOfTest.WebAii.ObjectModel.Element.GetXmlDocument(Element root, Boolean withAbsoluteIndex, Boolean allChildNodes, Boolean ignoreTestRegionTags)
   at ArtOfTest.WebAii.ObjectModel.Element.ToXml(Boolean allChildNodes, Boolean ignoreTestRegionTags, Boolean emitAbsIndex)
   at ArtOfTest.WebAii.ObjectModel.Element.ToXml(Boolean allChildNodes, Boolean ignoreTestRegionTags)
   at ArtOfTest.WebAii.Core.HtmlTreeCrawler.FindUsingHierarchicalClause(Element startNode, HtmlFindClause clause)
   at ArtOfTest.WebAii.Core.HtmlTreeCrawler.FindUsingHierarchicalClause(Element startNode, HtmlFindClause clause, Boolean includeRoot)
   at ArtOfTest.Common.TreeCrawler`3.Find(T startNode, IList`1 clauses, V expression, Boolean includeRoot, Boolean ignoreContraints)
   at ArtOfTest.Common.TreeCrawler`3.ByExpression(T startNode, V expression, Boolean includeRoot)
   at ArtOfTest.WebAii.Core.Find.ByExpression(HtmlFindExpression expression, Boolean includeRoot)
   at ArtOfTest.WebAii.Core.Find.ByExpression(HtmlFindExpression expression)
   at ArtOfTest.WebAii.ObjectModel.Element.Refresh()
   --- End of inner exception stack trace ---
   at ArtOfTest.WebAii.ObjectModel.Element.Refresh()
   at ArtOfTest.WebAii.ObjectModel.Element.Refresh(Boolean forceDomTreeRefresh)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at ArtOfTest.Common.WaitAsync.CallRefreshIfNeeded[T](T target)
   at ArtOfTest.Common.WaitAsync._worker_DoWork[T,V](Object waitParam)

There is a link on the side that opens a page in new window. In framework reference and different threads (including this forum) it is said to use WaitForNewBrowserConnect, but it is not working:

[Test]
        public void NewPageIssue()
        {
            Manager.Current.ActiveBrowser.NavigateTo("http://www.thomsons.com/auto-enrolment-staging-dates-and-cost-calculator");
 
            Manager.Current.ActiveBrowser.Find.ByXPath("//a[text()='Auto Enrolment Guide']").As<HtmlAnchor>().Click(); //in IE not found, exception
 
            Manager.Current.WaitForNewBrowserConnect("thomsons.com/aeguide", true, 10000); // in Chrome "Exception occured waiting for the new browser to connect." exception
        }

There also a strange error when trying to invoke "OnMouseOver" event in Chrome:
[Test]
        public void InvokeEventIssue()
        {
            string xpath = "//a[text()='Find us']";
 
            Manager.Current.ActiveBrowser.RefreshDomTree();
 
            Element anchor = Manager.Current.ActiveBrowser.Find.ByXPath(xpath);
 
            anchor.As<HtmlAnchor>().InvokeEvent(ScriptEventType.OnMouseOver); // "ExecuteCommand failed" exception in Chrome
        }

InvokeEvent from above throws the following:
ArtOfTest.WebAii.Exceptions.ExecuteCommandException was unhandled by user code
  Message=ExecuteCommand failed!
InError set by the client. Client Error:
Object [object Object] has no method 'parse'
BrowserCommand (Type:'Action',Info:'NotSet',Action:'InvokeEvent',Target:'ElementId (tagName: 'a',occurrenceIndex: '47')',Data:'onmouseover--@@--null',ClientId:'494163fc-0107-4773-a725-6787f71dd4ca',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'-1',InError:'True',Response:'Object [object Object] has no method 'parse'')
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.InvokeEvent(Element targetElement, ScriptEventType eventType)
       at ArtOfTest.WebAii.Controls.HtmlControls.HtmlControl.InvokeEvent(ScriptEventType eventType)
       at testProject.Tests.InvokeEventIssue() in C:\Users\userName\Desktop\testProject\testProject\tests\tests.cs:line 155
  InnerException:

Chrome version: 24.0.1312.57 m
IE version: 8
WebAii version: 2012.2.1204

So, as you can understand, it's very frustrating experience to get exceptions almost on each step, on different browsers on a real(production) site.

Can you please assist us with the issues from above?
Thank you,
Andrei.

2 Answers, 1 is accepted

Sort by
0
Accepted
Plamen
Telerik team
answered on 25 Feb 2013, 10:04 AM
Hi Andrei,

I am sorry to hear you are experiencing these issues. The first test you provided(IEIssue) works as expected on my machine in both IE and Chrome(see this video). However I was able to reproduce the issue using the other two tests. I logged a bug on this behavior which you can track here: PublicURL.

In the meantime, until the XPath issue is resolved, you can use different find logic to locate these elements. For example, to locate the 'Auto Enrolment Guide' link, you can use its 'title' attribute instead and this will work in all browsers.
Manager.Current.ActiveBrowser.WaitForElement(10000, "title=Automatic Enrolment Guide");

Regarding the Popup issue, you need to notify the framework about the browser instances that you want to be tracked by enabling new browser tracking. See this video demonstrating how to connect to a new browser window.

To overcome the OnMouseOver event issue, use the MouseHover() method instead. This will place the mouse pointer over the element and will trigger the OnMouseOver event if there is such event attached to that element. See this video.

For future reference, to optimize support response times, please file separate tickets or forum posts for separate unrelated issues. This also ensures better tracking for both parties..

All the best,
Plamen
the Telerik team
Quickly become an expert in Test Studio, check out our new training sessions!
Test Studio Trainings
0
Andrei
Top achievements
Rank 1
answered on 25 Feb 2013, 02:44 PM
Hi Plamen,

thank you for your reply - I've been able to solve "new browser" and "mouseover" issues.

I'll raise separate threads for any other issues that will appear.
Kind regards,
Andrei
Tags
General Discussions
Asked by
Andrei
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Andrei
Top achievements
Rank 1
Share this question
or