[Webtest] verifyXPath - dealing with xml namespaces

Michael Knapp webtest@lists.canoo.com
Mon, 12 Jun 2006 17:09:35 -0700


Hi - When I'm asking webtest to parse an xpath in a response (using
storeXPath, verifyXPath, etc), if there's a namespace as part of the
expression, jaxen barfs resolving the namespace.

EG, if the response looks like this:

<env:Envelope xmlns:env=3D"http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"=20
xmlns:xsi=3D"http://www.w3.org/2001/XMLSchema-instance"=20
xmlns:enc=3D"http://schemas.xmlsoap.org/soap/encoding/"=20
xmlns:ns0=3D"http://www.atg.com/atg.security"=20
xmlns:ns1=3D"http://www.atg.com/javax.servlet"=20
xmlns:ns2=3D"http://www.atg.com/webservices"
env:encodingStyle=3D"http://schemas.xmlsoap.org/soap/encoding/">
<env:Body><ns2:logoutUserResponse/>
</env:Body>
</env:Envelope>


And I try to do something like=20

<verifyXPath
Xpath=3D"//ns2:logoutUserResponse" />

I'll get  a similar message to this:


 Message was: Cannot resolve namespace prefix 'ns2'
[storeXPath] ERROR (com.canoo.webtest.steps.Step) - Cannot handle
unexpected exception in step StoreXPath at
/export/home/mknapp/canoo/webtests/UseCases/scratchUseCase.xml:86:  with
(taskName=3D"storeXPath", property=3D"XP", =
XPath=3D"ns2:logoutUserResponse")
[storeXPath] org.jaxen.UnresolvableException: Cannot resolve namespace
prefix 'ns2'


Any idea on how I can get this to resolve?

Thanks (and thanks for the prior help as well.....looks like this will
work nicely for  soap testing, assuming I  can get past these small
hurdles...)

mike