I recently added a couple of commands for dealing with toggle-buttons, ie. checkboxes and radio-buttons.

    check( locator )
    uncheck( locator )
    assertChecked( locator )
    assertNotChecked( locator )

As you can see, they currently just accept a single element-locator argument.

Now, the unique thing about toggle-buttons is that tend to appear in groups where each element has the *same* @name, but a different @value.

    <input type="checkbox" name="options" value="onions">
    <input type="checkbox" name="options" value="cheese">
    ...etc...

This makes the "name=" locator less useful, as it can only be used to locate the first toggle-button in the group. It's possible to access the checkboxes using other locator-types (e.g. dom, xpath), but name-based addressing would be more user-friendly, I think.

Therefore, I think we need to find a way to identify a toggle-button within a name-group, using a secondary attribute; typically 'value'. My first thought was that this could be done via a second, optional argument to the toggle-button commands:

    check( locator, selector )

e.g.

    | check | options | cheese |

Having started down that road, I'm now wondering whether it mightn't be better to simply extend the "name=" locator itself to support an optional "element selector" suffix, e.g.

    | check | options cheese | |

Primarily, it's because I think it would be cleaner to implement that way, and the result would be more general, as the extended "name=" locator could be useful for other commands, too, e.g.

    | verifyVisible | options cheese | |

Also, I think an "element selector" is really only useful in conjunction with name-based element addressing, anyway; there's no need of it for id, dom or xpath locators.

Any one have an opinion? Is matching the toggle-button value in the locator a bad move?

As an aside, I'm thinking of the "element selectors" as a generalisation of the existing "option specifiers" that are used in handling of <select> elements.

--
cheers, MikeW                            http://www.dogbiscuit.org/mdub/
_______________________________________________
Selenium-devel mailing list
Selenium-devel@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-devel

Reply via email to