Subj : Shouldn't getElementById use name attribute of INPUT control? To : netscape.public.mozilla.jseng From : ljwynne Date : Sat Sep 11 2004 08:51 pm HttpUnit seems to only look for the "id" attribute of an HTML element when executing the getElementById javascript and doesn't recognize the "name" attribute. In a browser this method will work for both "id" and "name" attributes. Given the following html: contents of page1.htm:
field1
This link does not work in HttpUnit
This HttpUnit test will fail: WebConversation wc = new WebConversation(); WebResponse resp = wc.getResponse( "http://localhost:7001/test/page1.htm"; ); resp.getLinkWith("This link does not work in HttpUnit").click(); assertEquals("Hello World", wc.popNextAlert()); with the following message: Event 'document.getElementById('field1').focus()' failed: TypeError: focus is not a function. But if you change the "name" attribute in the INPUT control to "id": field1
The same HttpUnit test passes. I noticed that in class HTMLElementBase there is an ArrayList _supportedAttributes that contains "name". Is there somewhere else that I should look. I would just change the "name" attributes to "id" but I have to take the code as is. I'd appreciate any thoughts you might have. -Larry .