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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
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.
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
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
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
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.
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