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 <[email protected]>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 <[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 >
_______________________________________________ Wtr-development mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-development
