Now thinking some more about it i have to agree with Jari - this adds
unnecessary API complexity. Regular user doesn't know much about DOM
or it's specifics and doesn't care if the :index, :xpath or :text are
part of DOM or not. They care only about simplicity and about the fact
that they could locate some element. That's all.

But adding #[] to elements container wouldn't hurt i guess. This means
that elements could behave like Array and include Enumerable. That
would be cool.

In short, leave :index as it is and add #[].

Jarmo

On Fri, Sep 10, 2010 at 2:16 AM, Jari Bakken <[email protected]> wrote:
> 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
_______________________________________________
Wtr-development mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-development

Reply via email to