HttpUnit and XPath
Julien Henry <[email protected]>
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I would like to use HttpUnit and XPath. I found this page :
http://idiacomputing.com/moin/HtmlTestingUsingXpath
It's now possible for me to check if an element is present thanks to
xpath. But now, I want to click on a link specified by it's XPath.
I have this code :
private Object getElementByXPath(String xpath) {
try {
Document rootNode = getResponse().getDOM();
XPath xpathObject = makeXpath(xpath);
return xpathObject.selectSingleNode(rootNode);
} catch (SAXException e) {
throw new RuntimeException(e);
} catch (JaxenException e) {
throw new RuntimeException(e);
}
}
public void clickElementByXPath(String xpath) {
Object o = getElementByXPath(xpath);
if (o instanceof Node) {
??????????????
}
else {
throw new RuntimeException("Don't know how to click on this
element");
}
}
So I get a Node thanks to XPath, but I don't know how to make httpunit
parse it and click on it.
Any idea ?
Thanks
Julien Henry
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.