Menu

#281 Problem with Xpath that returns set of attribute?

Latest SVN
closed
None
5
2012-10-21
2005-06-15
No

In a webtest step, I use:
xpath = new HtmlUnitXPath("//img/@src");
xpath.selectNodes(lastResponse);

selectNodes throw a ClassCastException in
com.gargoylesoftware.htmlunit.html.xpath.DocumentNavigator, at
line 93:

private DomNode parent_ = ((DomNode)

contextNode).getParentNode()

The direct reason is that contextNode contains an attribute, which
is represented by a java.util.Map.Entry instead of a DOMNode.

I'm using htmlunit-20050609.jar and jaxen-1.1-beta-6.jar

Discussion

  • Marc Guillemot

    Marc Guillemot - 2005-06-19

    Logged In: YES
    user_id=402164

    Can you:
    - provide all files (changes + new files) in the patch
    - use checkstyle to stay conform to htmlunit's coding style
    See http://htmlunit.sourceforge.net/submittingPatches.html
    for all details.

    • update your copy before to generate the patch:
      HtmlUnitXPathTest already contains testListAttributesResult.
      The only change that should occur there is that the
      notYetImplemented stuff should be removed as your patch is
      aimed to fix the problem.
     
  • Denis N. Antonioli

    Logged In: YES
    user_id=606305

    Just a single patch file this time.

     
  • Denis N. Antonioli

    Apply with "patch --unified --strip=0"

     
  • Marc Guillemot

    Marc Guillemot - 2005-06-21

    Logged In: YES
    user_id=402164

    Patch applied. Thanks.

    Note that I had to perform some manual changes because the
    case of the new files was incorrect in the patch file like:
    Index: src/java/com/gargoylesoftware/htmlunit/html/htmlAttr.java
    where the "h" of htmlAttr.java should have been uppercase.

     

Log in to post a comment.