Tuesday, April 14, 2009

XPath Voodoo

I had a use case for Canoo Web Test to verify the value of a table cell. In an attempt to obtain the value using an XPath query, I used the following expression:

My test failed, reporting that this expression didn't return any value at all. I verified this was the correct path by looking at the XHTML source. It was only through inspecting the XHTML using the Firebug plugin for Firefox did I see a mystery <tbody> tag. I'm not sure at which point that gets injected, or even why. The injection appears to be a misinterpretation of XTHML 1.0 strict (the specified DOCTYPE). When I added the <tbody> tag to the XPath expression -- which I remind you is not in the XHTML source -- the test passed. Here is the working expression:

I haven't figured out what I'm missing, yet.

No comments:

Post a Comment