Menu

public constructors for html classes

2002-09-26
2002-09-27
  • Troy Waldrep

    Troy Waldrep - 2002-09-26

    Hi,

    I'm building a xpath layer to use on top of httpunit in our environment and would like to be able to instantiate my own instances of WebForm, WebImage, WebLink, WebTable, etc.  Unfortunately, the constructors are either package-scoped or private (WebTable).  Would it be possible to open these classes up a little more or at least provide public factories to get the appropriate instances of HttpUnit classes associated with provided DOM Nodes?

     
    • Russell Gold

      Russell Gold - 2002-09-26

      Can you explain what you are trying to do? These classes are fairly tightly coupled to WebClient and WebResponse and HTMLPage, and in an upcoming change may not be created from DOM elements any more (although you would still be able to retrieve the underlying DOM, possibly cleaned up a bit).  It is therefore not so easy to guarantee their behavior in the presence of public constructors.

       
    • Troy Waldrep

      Troy Waldrep - 2002-09-26

      Basically I've added jaxen on top of httpunit so that we can use xpath expressions to locate page elements with a lot finer granularity than is currently possible.  Problem is that I get back a list of nodes instead of the desired httpunit classes (for elements with no associated httpunit class, this is no problem).  This would be ok if I could, in turn, create the associated junit classes, but I can't without making changes to httpunit that may not be compatible with future versions.  I have access to the appropriate instances of everything needed to create these classes (WebResponse, URL, frameName, Node, characterSet ), so I would think there should be a way for me to instantiate these in a way that will be compatible with future versions.

      regards,

      Troy

       
    • Troy Waldrep

      Troy Waldrep - 2002-09-26

      Basically I've added jaxen on top of httpunit so that we can use xpath expressions to locate page elements with a lot finer granularity than is currently possible.  Problem is that I get back a list of nodes instead of the desired httpunit classes (for elements with no associated httpunit class, this is no problem).  This would be ok if I could, in turn, create the associated junit classes, but I can't without making changes to httpunit that may not be compatible with future versions.  I have access to the appropriate instances of everything needed to create these classes (WebResponse, URL, frameName, Node, characterSet ), so I would think there should be a way for me to instantiate these in a way that will be compatible with future versions.

      regards,

      Troy

       
    • Troy Waldrep

      Troy Waldrep - 2002-09-27

      Sorry about the double-post.  I wasn't thinking when I refreshed my page. 

      Anyway, I was thinking a little further and since httpunit already creates these instances (WebLink, WebForm, WebTable, etc.) would it be possible to add support methods to ParsedHTML, WebResponse, etc. to return the HttpUnit instance associated with a given DOM Node instance?

      regards,

      Troy

       
      • Russell Gold

        Russell Gold - 2002-09-27

        That may be doable. I will look into it.  Note: if you use 'id' or 'name' attributes, you can already retrieve these objects. Just ask for the one with the matching attribute.

         
    • Troy Waldrep

      Troy Waldrep - 2002-09-27

      Thanks ... and yes I would love to be able to depend on the existence of these attributes, but unfortunately in this case that is something I won't be able to dictate.

      regards,

      Troy

       

Log in to post a comment.

Auth0 Logo