: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). 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. :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 . On Thu, Sep 9, 2010 at 16:16, Jari Bakken <[email protected]> wrote: > On Thu, Sep 9, 2010 at 6:45 PM, Ethan <[email protected]> wrote: > > For vapir, I am pondering on deprecating usage of :index in a hash of > > attributes specifying an element. I'm looking to get reactions on this > idea > > from watir devs. > > Basically, when using a hash, :index is a special case and is extracted > from > > the attributes hash. I'd prefer not to have that one hash key treated > > differently from every other, and I think that the alternative I propose > > (below) is more elegant all around. > > It's not just this one key though - :xpath, :text, :value are all > special cases (with the latter two being equivalent in some cases) - > which makes me wonder if there are also other reasons why you'd like > it removed? Just curious. :) > > > I would replace this functionality with index being specified as a > subscript > > of element collections. That is, instead of: > > container.element(:class => 'some class', :index => 2) > > you'd do: > > container.elements(:class => 'some class')[2] > > The latter is already supported in vapir's master, though not yet > released > > as a gem (due to difficulties with some cases of subscript being > 0-indexed, > > I don't really have a strong opinion on this, but I have no problem > removing :index if there is consensus for that. Passing a selector > hash to the plural Container methods is supported in watir-webdriver. > > So ~1 from me. > _______________________________________________ > Wtr-development mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/wtr-development >
_______________________________________________ Wtr-development mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-development
