send_keys to some input element

36 views
Skip to first unread message

Al

unread,
Sep 6, 2007, 2:22:11 AM9/6/07
to Watir General
Is there any good way to send keystrokes to some specific input
element? Currently I use the next ugly code that does this:

ie.text_field(:name, "user_name").set("") # this should activate the
element name="user_name"
sleep 1
ie.send_keys("qwerty")

For some reason it doesn't work in Vista.

Ken Lim

unread,
Sep 6, 2007, 5:09:48 AM9/6/07
to watir-...@googlegroups.com
Hi,

Good day.

Any error message?

Sorry but can't replicate your problem because I don't access to a Vista machine.

A possibility is by inserting a 'focus' before the ie.send_keys
Modified code as follows:

ie.text_field(:name, "user_name").focus
ie.send_keys


Regards,


On 9/6/07, Al < oleg.i...@gmail.com> wrote:

Is there any good way to send keystrokes to some specific input
element? Currently I use the next ugly code that does this:

ie.text_field(:name, "user_name").set("") # this should activate the
element name="user_name"
sleep 1
ie.send_keys ("qwerty")

Al

unread,
Sep 6, 2007, 6:50:20 AM9/6/07
to Watir General
> Any error message?

No, there are no error messages, but it writes the send_keys keystroke
into url tab (because it is the current active element).
I tried:
ie.text_field(:name, "name").focus
sleep 1
ie.send_keys("hello")
The result is the same. The word "hello" is displayed in the url bar.

Reply all
Reply to author
Forward
0 new messages