or
[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();
}
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)
[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
}
[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
}
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:
"try {AppName.WindowName.OK} catch (System.Exception) {}
"
and if element is not found taking appropriate actions in catch. This work for me with the limitation that it slows down my test with 10 seconds for each hidden element invocation.