Hi all,

Looks like there's a bug in PageBot.locateElementByName, when retrieving a
form array element. e.g.:
<input type="radio" name="radioArray" value="one"> Option #1
<input type="radio" name="radioArray" value="two"> Option #2

Accessing this element via form.elements.radioArray will return an array of
the radio elems, of length 2 in the above example. However calling
locateElementByName("radioArray", ...) only returns the first radio: it's
the first element in the dom it finds whose name matches. Seems like if
you're searching by name you would in fact want it to return the grouped
element, as opposed to by id or anything else where you'd be targeting a
unique dom element.

BTW the fix is simple, here's the diff on PageBot.locateElementByName:

        if (testElement.name && testElement.name === identifier) {
<               return testElement;
>               return (testElement.form) ?
testElement.form.elements[testElement.name] : testElement;
        }

Ordinarily you wouldn't run into this as you'd access such elements
directly, e.g. click | document.forms[0].elements.radioArray[1]. However I'm
adding "check"/"uncheck" commands to give us a little more control, and want
to provide the same locator syntax support as other commands, e.g. (un)check
| radioArray | value="two", or index=1, etc. This requires that
locateElementByName returns the grouped element.

This change makes sense to me, but I can also see how it might be dodgy to
have locateElementByName sometimes return an element and sometimes an array.
Anyone have an opinion?

Thanks,
Elaine
_______________________________________________
Selenium-devel mailing list
Selenium-devel@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-devel

Reply via email to