On Apr 23, 2009, at 1:40 PM, Amelia A Lewis wrote:
Hey, Rob. :-)
I'd love to use XSL; how do I do that inside webtest? I didn't see
anything particulary obvious (and my groovy skills are very clearly
subpar, at the moment). I was hoping to see something in the filters,
but they seem a bit coarser-grained than that.
I tend to do this in a separate test setup outside of webtest. (using
webtest mainly for javascript.)
But, perhaps a custom XSL step similar to the VerifySchema step (or
perhaps VerifySchema will do what you need?):
http://webtest-community.canoo.com/wiki/space/Contributions+and+Uploads/VerifySchema
-Rob
Amy!
On Thu, 23 Apr 2009 12:43:32 -0400, Robert Koberg wrote:
Hi Amy!
FWIW, a simple XSL works really well for these types of things. I
mention XSL as opposed to XQuery because you can relatively easily
generate the XSL and version 1.0 is in the JVM.
best,
-Rob
On Apr 23, 2009, at 12:19 PM, Amelia A Lewis wrote:
This might be useful to others.
The syntax of the accessor for "getXPathHelper()" is slightly odd:
probably because it has two caps initially, they both have to appear
(whereas the references to the older threads (see below) show
"xPathHelper" which results in a null pointer).
If you do much with namespaces (verifying XML), this macro might
be of
interest:
<macrodef name="namespace"
description="define namespace for xpath">
<attribute name="prefix" />
<attribute name="uri" />
<sequential>
<groovy>
step.context.XPathHelper.namespaceContext.addNamespace("@{prefix}",
"@{uri}")
</groovy>
</sequential>
</macrodef>
You can then use it like this:
<webtest>
<config ... />
<namespace prefix="ex" namespace="http://www.example.com/" />
<invoke ... />
<verifyXPath xpath="ex:a/ex:b/ex:etc" />
</webtest>
This is less apt to produce typos (the groovy bit is only specified
once, and then the parameters are fed to it as needed).
Amy!
On Wed, 22 Apr 2009 22:12:02 -0400, Amelia A Lewis wrote:
Heyo.
I see from WT-253 that the issue around namespaces in XPath
verification has been closed. I cannot figure out how to make it
work.
In a relatively simple XML document with a default namespace
(xmlns="http://www.example.com/" on the root element,
"response"), none
of the following work:
<verifyXpath xpath="/response/getCurrentUser/name" value="name" />
(error: no node matched)
(this is expected; it shouldn't match)
<verifyXpath xmlns:ex="http://www.example.com/"
xpath="/response/getCurrentUser/name" value="name" />
(error: prefix must be declared)
Similarly if the namespace declaration is promoted to the
containing
"webtest" element and beyond.
This thread:
http://lists.canoo.com/pipermail/webtest/2006q4/007358.html (from
2006)
points at other threads that suggest solving things with a small
groovy
script. The pointed-at script is no longer correct (null
pointer), but
a little patience leads one to
step.context.getXPathHelper().registerGlobalNamespace("ex",
"http://www.example.com/"), which also yields: prefix must be
declared.
And yet the issue was closed, for 2.5. I can't find any examples
of
how to do it "right", though. Anyone have a pointer?
It would be nice to have <namespace prefix="ex"
uri="http://www.example.com/" /> as child elements of "config",
but I
don't see any indication that it might be so straightforward. I
might
have to patch it to do that (that way the namespaces would be
defined
in a reasonably predictable location, and valid for all the
documents
processed within the containing webtest element, presumably), but I
thought that I should ask first, and see if someone can point me
at an
existing solution.
Oh, I'm using the 3.0 distribution, rather than the nightly.
Amy!
--
Amelia A. Lewis amyzing {at} talsever.org
According to Business Week, in the 1990s the ratio between a chief
executive's salary and the takehome pay of the typical, feckless,
whining grunt on the shopfloor rose from 85:1 to 475:1. (In the UK,
which is seeing a vigorous popular backlash against "fat cat" pay
packets, the ratio is 24:1).
-- The Register
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest
_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest