Hello,
This is in response to a previous posting on this list with the above subject line. I am copying the content of that post below:
Is there any solution to the problem outlined below?
I am using struts and my <input> elements are conerted to 'name' instead of ID. Therefore, the assertFormElement(…) doesn't work because it is looking for ID.
So short of implementing the switch mentioed below, myself, is there a better solution?
TIA,
Pankaj
FWIW, here's the source code that is looking for ID:
From HttpUnitDialog.java
private Element walkDOM(Element element, String anID) {
if (element.getAttribute("id").equals(anID) || element.getAttribute("ID").equals(anID))
return element;
NodeList children = element.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE) {
Element el = walkDOM((Element) child, anID);
if (el != null)
return el;
}
}
return null;
}
From: Nick Neuberger <[EMAIL PROTECTED]>
Not seeing form element �
2005-01-05 10:00
Here is a thought?
In some cases, or some applications, the ID is the same as the Name.
What would everyone think about about a switch inside jwebunit that uses the
id attrib instead of the name attrib?
Like you could set method such as.
WebTester.switchNameToIdAttribute(true);
Inside jWebUnit the framework, when it should compare a "name" attrib, it
will check the "id" attrib instead.
This seems like the best approach since many assertions in jwebunit use the
"name".
Would this help out in STRUTS based applications as well.
Thoughts????
HTH...
Nick Neuberger
> -----Original Message-----
> From: Todd O"Bryan [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 04, 2005 8:47 PM
> To: Olaf Kock
> Cc: [EMAIL PROTECTED]
> Subject: Re: [Jwebunit-users] Not seeing form element
>
>
> Uh-oh. Tapestry assigns those names. I can only control the id.
>
> Any workarounds for a check by id?
>
> Todd
>
> On Jan 4, 2005, at 6:49 AM, Olaf Kock wrote:
>
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > Todd O"Bryan wrote:
> >
> > | As you can see, there really is a form element with
> id="username",
> > even
> > | if the framework can"t see it. Any ideas what"s going on?
> >
> > Hi,
> >
> > the framework complains that it can"t find an element with /name/
> > "username", not with /id/ "username". ;-)
> >
> > assertFormElementPresent("$TextField") should work better (if "$" is
> > processed as is).
> >
> > Cheers,
> >
> > Olaf
