[Webtest] htmlid validation

Marc Guillemot Marc Guillemot <mguillemot@yahoo.fr>
Mon, 29 Sep 2008 11:30:48 +0200


Hi Lisa,

ok, the problem was due to the single quote that wasn't "escaped" when
used in an XPath expression to find the right node.

This should now be fixed in build 1717.

Cheers,
Marc.
-- 
Web: http://www.efficient-webtesting.com
Blog: http://mguillem.wordpress.com

Lisa Crispin wrote:
> Sure, here it is, thanks.
> 
> c:\eclipse_projects\fast401k\src\web_test\SmokeTest\ManageProductDocuments.xml:51: Unexpected exception caught: java.lang.RuntimeException
> 	at com.canoo.webtest.steps.StepUtil.handleException(StepUtil.java:120)
> 
> 	at com.canoo.webtest.steps.Step.handleException(Step.java:379)
> 	at com.canoo.webtest.steps.Step.execute(Step.java:110)
> 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> 	at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
> 
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
> 
> 	at org.apache.tools.ant.Task.perform(Task.java:348)
> 	at com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequence.java:43)
> 	at com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java:31)
> 
> 	at com.canoo.webtest.steps.Step.execute(Step.java:101)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
> 	at org.apache.tools.ant.Task.perform(Task.java:348)
> 	at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:206)
> 
> 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> 	at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
> 	at org.apache.tools.ant.Task.perform(Task.java:348)
> 	at org.apache.tools.ant.Target.execute(Target.java:357)
> 
> 	at org.apache.tools.ant.Target.performTasks(Target.java:385)
> 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> 	at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
> 
> 	at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> 	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
> 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> 	at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
> 
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
> 
> 	at org.apache.tools.ant.Task.perform(Task.java:348)
> 	at org.apache.tools.ant.Target.execute(Target.java:357)
> 	at org.apache.tools.ant.Target.performTasks(Target.java:385)
> 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> 
> 	at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
> 	at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> 	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
> 
> 	at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
> 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
> 
> 	at org.apache.tools.ant.Task.perform(Task.java:348)
> 	at org.apache.tools.ant.Target.execute(Target.java:357)
> 	at org.apache.tools.ant.Target.performTasks(Target.java:385)
> 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> 
> 	at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
> 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
> 	at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> 
> 	at org.apache.tools.ant.Main.runBuild(Main.java:698)
> 	at org.apache.tools.ant.Main.startAnt(Main.java:199)
> 	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
> 	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
> 
> Caused by: java.lang.RuntimeException: Could not retrieve XPath >.//input[@type='radio' and @name='docProviderIds['adv']' and @value='TPA']< on HtmlForm[<form method="post">]
> 
> 	at com.gargoylesoftware.htmlunit.html.xpath.XPathUtils.getByXPath(XPathUtils.java:85)
> 	at com.gargoylesoftware.htmlunit.html.DomNode.getByXPath(DomNode.java:1328)
> 	at com.canoo.webtest.steps.form.SetRadioButton.findFields(SetRadioButton.java:38)
> 
> 	at com.canoo.webtest.steps.form.AbstractSetFieldStep.doExecute(AbstractSetFieldStep.java:144)
> 	at com.canoo.webtest.steps.Step.execute(Step.java:101)
> 	... 58 more
> Caused by: javax.xml.transform.TransformerException: Expected ], but found: adv
> 
> 	at org.apache.xpath.compiler.XPathParser.error(XPathParser.java:608)
> 	at org.apache.xpath.compiler.XPathParser.consumeExpected(XPathParser.java:526)
> 	at org.apache.xpath.compiler.XPathParser.Predicate(XPathParser.java:1935)
> 
> 	at org.apache.xpath.compiler.XPathParser.Step(XPathParser.java:1724)
> 	at org.apache.xpath.compiler.XPathParser.RelativeLocationPath(XPathParser.java:1633)
> 	at org.apache.xpath.compiler.XPathParser.LocationPath(XPathParser.java:1595)
> 
> 	at org.apache.xpath.compiler.XPathParser.PathExpr(XPathParser.java:1315)
> 	at org.apache.xpath.compiler.XPathParser.UnionExpr(XPathParser.java:1234)
> 	at org.apache.xpath.compiler.XPathParser.UnaryExpr(XPathParser.java:1140)
> 
> 	at org.apache.xpath.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1061)
> 	at org.apache.xpath.compiler.XPathParser.AdditiveExpr(XPathParser.java:1003)
> 	at org.apache.xpath.compiler.XPathParser.RelationalExpr(XPathParser.java:928)
> 
> 	at org.apache.xpath.compiler.XPathParser.EqualityExpr(XPathParser.java:868)
> 	at org.apache.xpath.compiler.XPathParser.AndExpr(XPathParser.java:832)
> 	at org.apache.xpath.compiler.XPathParser.OrExpr(XPathParser.java:805)
> 
> 	at org.apache.xpath.compiler.XPathParser.Expr(XPathParser.java:788)
> 	at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:127)
> 	at com.gargoylesoftware.htmlunit.html.xpath.XPathAdapter.<init>(XPathAdapter.java:83)
> 
> 	at com.gargoylesoftware.htmlunit.html.xpath.XPathUtils.evaluateXPath(XPathUtils.java:107)
> 	at com.gargoylesoftware.htmlunit.html.xpath.XPathUtils.getByXPath(XPathUtils.java:63)
> 	... 62 more
> --- Nested Exception ---
> 
> java.lang.RuntimeException: Could not retrieve XPath >.//input[@type='radio' and @name='docProviderIds['adv']' and @value='TPA']< on HtmlForm[<form method="post">]
> 
> 	at com.gargoylesoftware.htmlunit.html.xpath.XPathUtils.getByXPath(XPathUtils.java:85)
> 	at com.gargoylesoftware.htmlunit.html.DomNode.getByXPath(DomNode.java:1328)
> 	at com.canoo.webtest.steps.form.SetRadioButton.findFields(SetRadioButton.java:38)
> 
> 	at com.canoo.webtest.steps.form.AbstractSetFieldStep.doExecute(AbstractSetFieldStep.java:144)
> 	at com.canoo.webtest.steps.Step.execute(Step.java:101)
> 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> 
> 	at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
> 
> 	at org.apache.tools.ant.Task.perform(Task.java:348)
> 	at com.canoo.webtest.ant.TestStepSequence.executeSteps(TestStepSequence.java:43)
> 	at com.canoo.webtest.ant.TestStepSequence.doExecute(TestStepSequence.java:31)
> 
> 	at com.canoo.webtest.steps.Step.execute(Step.java:101)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
> 	at org.apache.tools.ant.Task.perform(Task.java:348)
> 	at com.canoo.webtest.ant.WebtestTask.execute(WebtestTask.java:206)
> 
> 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> 	at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
> 	at org.apache.tools.ant.Task.perform(Task.java:348)
> 	at org.apache.tools.ant.Target.execute(Target.java:357)
> 
> 	at org.apache.tools.ant.Target.performTasks(Target.java:385)
> 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> 	at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
> 
> 	at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> 	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
> 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> 	at sun.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
> 
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
> 
> 	at org.apache.tools.ant.Task.perform(Task.java:348)
> 	at org.apache.tools.ant.Target.execute(Target.java:357)
> 	at org.apache.tools.ant.Target.performTasks(Target.java:385)
> 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> 
> 	at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:38)
> 	at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> 	at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:416)
> 
> 	at org.apache.tools.ant.taskdefs.CallTarget.execute(CallTarget.java:105)
> 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)
> 
> 	at org.apache.tools.ant.Task.perform(Task.java:348)
> 	at org.apache.tools.ant.Target.execute(Target.java:357)
> 	at org.apache.tools.ant.Target.performTasks(Target.java:385)
> 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)
> 
> 	at org.apache.tools.ant.Project.executeTarget(Project.java:1298)
> 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
> 	at org.apache.tools.ant.Project.executeTargets(Project.java:1181)
> 
> 	at org.apache.tools.ant.Main.runBuild(Main.java:698)
> 	at org.apache.tools.ant.Main.startAnt(Main.java:199)
> 	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
> 	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
> 
> Caused by: javax.xml.transform.TransformerException: Expected ], but found: adv
> 	at org.apache.xpath.compiler.XPathParser.error(XPathParser.java:608)
> 	at org.apache.xpath.compiler.XPathParser.consumeExpected(XPathParser.java:526)
> 
> 	at org.apache.xpath.compiler.XPathParser.Predicate(XPathParser.java:1935)
> 	at org.apache.xpath.compiler.XPathParser.Step(XPathParser.java:1724)
> 	at org.apache.xpath.compiler.XPathParser.RelativeLocationPath(XPathParser.java:1633)
> 
> 	at org.apache.xpath.compiler.XPathParser.LocationPath(XPathParser.java:1595)
> 	at org.apache.xpath.compiler.XPathParser.PathExpr(XPathParser.java:1315)
> 	at org.apache.xpath.compiler.XPathParser.UnionExpr(XPathParser.java:1234)
> 
> 	at org.apache.xpath.compiler.XPathParser.UnaryExpr(XPathParser.java:1140)
> 	at org.apache.xpath.compiler.XPathParser.MultiplicativeExpr(XPathParser.java:1061)
> 	at org.apache.xpath.compiler.XPathParser.AdditiveExpr(XPathParser.java:1003)
> 
> 	at org.apache.xpath.compiler.XPathParser.RelationalExpr(XPathParser.java:928)
> 	at org.apache.xpath.compiler.XPathParser.EqualityExpr(XPathParser.java:868)
> 	at org.apache.xpath.compiler.XPathParser.AndExpr(XPathParser.java:832)
> 
> 	at org.apache.xpath.compiler.XPathParser.OrExpr(XPathParser.java:805)
> 	at org.apache.xpath.compiler.XPathParser.Expr(XPathParser.java:788)
> 	at org.apache.xpath.compiler.XPathParser.initXPath(XPathParser.java:127)
> 
> 	at com.gargoylesoftware.htmlunit.html.xpath.XPathAdapter.<init>(XPathAdapter.java:83)
> 	at com.gargoylesoftware.htmlunit.html.xpath.XPathUtils.evaluateXPath(XPathUtils.java:107)
> 	at com.gargoylesoftware.htmlunit.html.xpath.XPathUtils.getByXPath(XPathUtils.java:63)
> 
> 	... 62 more
> 
> 
> 
> 
> On Wed, Sep 24, 2008 at 1:17 AM, Marc Guillemot <mguillemot@yahoo.fr
> <mailto:mguillemot@yahoo.fr>> wrote:
> 
>     Hi Lisa,
> 
>     can you provide the stacktrace of the exception you get?
> 
>     Cheers,
>     Marc.
>     --
>     Web: http://www.efficient-webtesting.com
>     Blog: http://mguillem.wordpress.com
> 
>     Lisa Crispin wrote:
>     > Our app uses Spring velocity macros (I think that's the right
>     > terminology) to generate HTML. In one new page in the UI, it's
>     > generating ids and names that look like this:
>     >
>     > id="docProviderIds['aaa']"
>     >
>     > My WebTest script gets a Java runtime exception. I presumed this is
>     > because of the single quotes within the double quotes, as my
>     > understanding is that this is invalid. However, when we run that page
>     > through the WC3 validator, it doesn't complain about the quotes, but
>     > about the bracket:
>     >
>     > /character "[" is not allowed in the value of attribute "ID"/
>     > We have lots of pages where the html ID and name have square brackets,
>     > but WebTest never had a problem with those
>     >
>     > Are we wrong about the single quote within the double quote?
>     WebTest (or
>     > HtmlUnit) really unhappy with the brackets? But if that's the
>     case, why
>     > doesn't it complain about them in many other pages for which we have
>     > scripts?
>     >
>     > Is there any way to tell WebTest or HtmlUnit to ignore certain
>     things in
>     > the HTML, relax the validation, as it were (I don't think so, but I
>     > thought I'd ask).
>     >
>     > Thanks,
>     > Lisa
>     > //
>     >
>     > --
>     > Lisa Crispin
>     > Co-author with Janet Gregory, Agile Testing
>     > http://www.agiletester.ca
>     > http://lisa.crispin.home.att.net
>     > http://lisacrispin.blogspot.com
> 
>     _______________________________________________
>     WebTest mailing list
>     WebTest@lists.canoo.com <mailto:WebTest@lists.canoo.com>
>     http://lists.canoo.com/mailman/listinfo/webtest
> 
> 
> 
> 
> -- 
> Lisa Crispin
> Co-author with Janet Gregory, Agile Testing
> http://www.agiletester.ca
> http://lisa.crispin.home.att.net
> http://lisacrispin.blogspot.com