[Webtest] namespaces and verifyxpath

Luca Scheuring webtest@lists.canoo.com
Thu, 29 Jul 2004 09:38:13 +0200


good morning!

I use verifyxpath and storexpath in different tests. with some webpages,
these steps simply don't work (e.g. I get "no match for xpath expression
/html/head/title; see example below). it took me some time to find out the
problem: when a webpage specifies a namespace, xpath evaluation fails. some
of the webpages I have to check are written in the XHTML standard. such
pages need to have the namespace set in the root (--> <html>) element. 
(see http://www.w3.org/TR/1999/PR-xhtml1-19991210/#docconf)

example:
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>my title</title></head>
<body>...</body>
</html>

for the xpath expression "/html/head/title" I don't get a match. when I
remove the namespace, it works of couse.

any ideas for a workaround except changing the html sources?

thanks, 

--luca