On Fri, Sep 10, 2010 at 12:22 AM, Ethan <[email protected]> wrote: > :xpath is a special case (there are a few of these), but it's not extracted > from a hash if one is given. In vapir, using a hash implies that all of the > hash pairs correspond to DOM attributes and attribute values of the dom > element. :xpath isn't supported as a hash key, since it's not an attribute > of the element on the dom, so no exception is made for it. It is only > supported as a 'how' in (how, what) arguments - that is to say, > > element(:xpath, '//whatever') > will use an xpath locator, whereas > element(:xpath => '//whatever') > will look for an element with an attribute called 'xpath' with a value of > '//whatever' (which won't exist).
This is a bug, in my opinion. > I think that this makes sense, because the only reason to use a hash is to > combine multiple selectors. There is no way to combine :xpath with any other > selector. (theoretically, maybe, but I haven't implemented it that way and > don't plan to.) So, no exception is made for :xpath as a hash key. Right. watir-webdriver currently will just use the xpath given and ignore anything else - a more correct approach would probably be to raise if additional selectors are given. But I think not allowing (:xpath => "foo") as an equivalent of (:xpath, "foo") is just adding unnecessary API complexity and will be super confusing to users. The less exceptions and special rules to remember, the better. > :text and :value aren't special cases, they are both attributes on the dom > and can be sensibly used together in a hash of attributes. > I wrote a bit about this for the vapir wiki (just now, since I haven't done > a good job documenting it anywhere previously) - it's up > at http://wiki.github.com/vapir/vapir/locators . > This is a minor point, but :text and :value are not "attributes on the dom" according to the HTML spec (they do appear, but only on a small set of elements). :text in particular is definitely special cased in Watir (e.g. it should match against the inner text for <textarea> and against the @value attribute for <input type=text>). _______________________________________________ Wtr-development mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-development
