[Webtest] verifyXPath - dealing with xml namespaces

Paul King webtest@lists.canoo.com
Tue, 13 Jun 2006 22:47:25 +1000


If you use the snapshot (HEAD) version of HtmlUnit, the following
works for me as a workaround:

    <!-- simulate namespace aware <verifyXPath xpath="//ns2:logoutUserResponse"/> -->
    <groovy>
        def root = step.context.currentResponse.xmlDocument
        org.jaxen.XPath xpath = new org.jaxen.dom.DOMXPath("//ns2:logoutUserResponse")
        xpath.addNamespace("ns2", "http://www.atg.com/webservices")
        assert xpath.selectNodes(root).size() == 1
    </groovy>

Cheers, Paul.

Marc Guillemot wrote:
> Hi Mike,
> 
> this seems to be related to htmlunit's XML parsing bug:
> http://sourceforge.net/tracker/index.php?func=detail&aid=1496491&group_id=47038&atid=448266
> 
> XPath on XMLPage are evaluated using Jaxen's DOMXPath. I suppose that it is
> necessary to retrieve the namespaces from the Document and to inform this
> XPath object about the available namespaces (using the namespace context).
> If you want to investigate your patch is welcome ;-)
> 
> Marc.
> --
> View this message in context: http://www.nabble.com/verifyXPath---dealing-with-xml-namespaces-t1777411.html#a4841985
> Sent from the WebTest forum at Nabble.com.
> 
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
> 
>