[Wtr-development] send_keys methods differences between watir and watir-webdriver

Jarmo jarmo.p at gmail.com
Mon Sep 19 17:02:44 EDT 2011


Sorry for answering so late - so in the essence, what's the difference
between these two invocations:
send_keys(["hello", :control, "i"])
send_keys("hello", [:control, "i"])

Does it mean that the first one presses hello and "control + i" and then
releases the keys and the second one releases "hello" keys before sending
"control + i"?

Jarmo

On Sat, Sep 10, 2011 at 10:13 PM, Simon Stewart
<simon.m.stewart at gmail.com>wrote:

> send_keys in webdriver is "sticky" until the end of the array of
> parameters sent to the method or the magic "keys.NULL" character is
> seen. Therefore to type "hello" followed by "control + i":
>
> send_keys(["hello", :control, "i"])
>
> The idea behind this is to allow complex chording to be done in a
> relatively natural way via send_keys. For more advanced control, we
> provided the advanced user interaction API.
>
> Simon
>
> On Sat, Sep 10, 2011 at 1:19 PM, Jarmo <jarmo.p at gmail.com> wrote:
> > I know the difference between #set and #send_keys, but i was asking what
> was
> > the syntax for let's say typing word "hello" and then doing :control,
> 'a'.
> > Would it be:
> > #send_keys('hello', [:control, 'a'])
> > Does it mean technically that:
> > 1) string "sent" with keypress-keyrelease
> > 2) control is sent with keypress
> > 3) "a" is sent with keypress
> > 4) control and "a" are sent with keyrelease?
> > What about control+alt+a?
> > #send_keys([:control, :alt, 'a'])?
> > And this:
> > 1) control is sent with key-press
> > 2) alt is sent with key-press
> > 3) "a" is sent with key-press
> > 4) all keys are released
> > I'm asking these questions since Watir::IE#send_keys forwards all it's
> > arguments to RAutomation::Window#send_keys, which means that the change
> > should be mainly there.
> > Jarmo
> > On Sat, Sep 10, 2011 at 1:20 PM, Alister Scott <alister.scott at gmail.com>
> > wrote:
> >>
> >> 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 <jarmo.p at gmail.com> 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 <
> alister.scott at gmail.com>
> >>> 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
> >>>> Wtr-development at rubyforge.org
> >>>> http://rubyforge.org/mailman/listinfo/wtr-development
> >>>
> >>>
> >>> _______________________________________________
> >>> Wtr-development mailing list
> >>> Wtr-development at rubyforge.org
> >>> http://rubyforge.org/mailman/listinfo/wtr-development
> >>
> >>
> >> _______________________________________________
> >> Wtr-development mailing list
> >> Wtr-development at rubyforge.org
> >> http://rubyforge.org/mailman/listinfo/wtr-development
> >
> >
> > _______________________________________________
> > Wtr-development mailing list
> > Wtr-development at rubyforge.org
> > http://rubyforge.org/mailman/listinfo/wtr-development
> >
> _______________________________________________
> Wtr-development mailing list
> Wtr-development at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/wtr-development/attachments/20110920/ea84e71a/attachment-0001.html>


More information about the Wtr-development mailing list