Depends on whether you want to send some text, or set a field.
I usually use element.set('hello') which does what it says, sets it to
'hello'

If you wanted to send the text, you'd call element.send_keys('hello'), the
difference being this doesn't clear the field first, so it'll just fire in
this text string to what is already there.

The usage therefore is, element.set for setting a value, element.send_keys
for performing an action, like element.send_keys([:control, 'a']) would
select all in a field.

You wouldn't want to use .set with special keys as it would replace what you
are trying to select!

Does this make sense?

Cheers,
Alister

Alister Scott
Brisbane, Australia
Watir Web Master: http://watir.com
Blog: http://watirmelon.com
LinkedIn: http://www.linkedin.com/in/alisterscott

"There are two ways to get enough: One is to continue to accumulate more and
more. The other is to desire less." *~ G. K. Chesterton*


On Sat, Sep 10, 2011 at 5:10 PM, Jarmo <[email protected]> wrote:

> And how would you send just some text with Watir-WebDriver, e.g. 'hello'?
> send_keys "hello"? So, as i understand then the array's are key combinations
> and just a symbol is a special key and string is just as is?
>
> I'd hate to keep something just for backwards compatibility until forever
> :/
>
> J.
>
> On Sat, Sep 10, 2011 at 8:30 AM, Alister Scott <[email protected]>wrote:
>
>> Hi,
>>
>> I've noticed there's some differences between the .send_keys method in
>> Watir and Watir-WebDriver.
>>
>> 1) .send_keys only works at the *browser* level in watir, whereas it
>> works at the browser and *element* level in watir-webdriver
>> 2) .send_keys requires special strings in watir (eg. "{ENTER}") whereas
>> send_keys uses chains of symbols (and arrays of symbols) in watir-webdriver
>> (eg b.element.send_keys [:control, 'a'], :backspace): full list here:
>> http://watirwebdriver.com/sending-special-keys/
>>
>> I think the watir-webdriver API is better in this regard, so, what do
>> people think about incorporating the element level send_keys, and the use of
>> symbols into Watir?
>> I imagine we'd need to leave the special string support for backwards
>> compatibility.
>>
>> Cheers,
>> Alister
>>
>> Alister Scott
>> Brisbane, Australia
>> Watir Web Master: http://watir.com
>> Blog: http://watirmelon.com
>> LinkedIn: http://www.linkedin.com/in/alisterscott
>>
>> "There are two ways to get enough: One is to continue to accumulate more
>> and more. The other is to desire less." *~ G. K. Chesterton*
>>
>> _______________________________________________
>> 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
>
_______________________________________________
Wtr-development mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-development

Reply via email to