HTTPUnit says it supports the DOM to the extent of Text controls having read/write Value properties. The problem is, it looks to me to be read-only, or at least any writes never get written back to the actual DOM tree.
Here's a snippet of code that is trying to set a field value. (Could try to set Parameters directly but it would be really useful to be able to set them through the DOM too, e.g. to set them by name or id.)
Can anyone tell me how to set text values in the DOM? Thanks in advance,
HTTPUnit says it supports the DOM to the extent of Text controls having read/write Value properties. The problem is, it looks to me to be read-only, or at least any writes never get written back to the actual DOM tree.
Here's a snippet of code that is trying to set a field value. (Could try to set Parameters directly but it would be really useful to be able to set them through the DOM too, e.g. to set them by name or id.)
Can anyone tell me how to set text values in the DOM? Thanks in advance,
Max Wilson
public void setField(String fieldname, String val) {
...
WebResponse f = (WebResponse) i.next();
try {
NodeList nl = f.getDOM().getElementsByTagName("INPUT");
for(int ni = 0; ni < nl.getLength(); ++ni) {
HTMLElement n = (HTMLElement) nl.item(ni);
if(n != null && n.getAttribute("type").equals("text")) {
String s = n.getAttribute("name");
if(s.equals(fieldname)) {
n.setAttribute("value", val);
n.setNodeValue(val);
Assert.assertEquals(val, n.getAttribute("value"));
f.getForms()[0].setParameter(fieldname, val);
Assert.assertEquals(val, getField(fieldname));
return;
}
}
}
} catch(SAXException e) {
ErrorLogger.log(e);
}
}
}