Carriage Return in Text_Field's set method

28 views
Skip to first unread message

Bach Le

unread,
Apr 16, 2008, 3:02:45 PM4/16/08
to Watir General
Is there an easy way to do a carriage return in text_field's set
method?

I've tried these, and none of them work

$IE0.form(:id, 'id').text_field(:id, id).set('text\r\n')
$IE0.form(:id, 'id').text_field(:id, id).set('text\n')
$IE0.form(:id, 'id').text_field(:id, id).set('text\r')


-Bach

Alex Collins

unread,
Apr 16, 2008, 3:12:58 PM4/16/08
to watir-...@googlegroups.com
Try using double quotes around the string.

Single-quoted strings only support \' (single quote) and \\ (backslash)
escape sequences, I believe.

Alex

andy sipe

unread,
Apr 16, 2008, 4:05:52 PM4/16/08
to watir-...@googlegroups.com
There was also some weirdness around this. Check the NG archives.

--andy

--

----------------------------------------------------
Andy Sipe
http://zbarzone.blogspot.com/
----------------------------------------------------

marekj

unread,
Apr 16, 2008, 4:08:37 PM4/16/08
to watir-...@googlegroups.com
text_field sets values for these html input types ["text", "password", "textarea"]
if you have a textarea you can set multiline value using ruby heredoc

value = <<eof
this is line one
second line of message
and another line
eof

ie.text_field().set(value)


or inline
ie.text_field().set("this is line one\n\rThis is line two\n\rand another line")


marekj

www.testr.us | Free Watir Introduction in Dallas, TX. Looking for new clients.

Bach Le

unread,
Apr 16, 2008, 4:16:38 PM4/16/08
to Watir General
Actually, I wanted to simulate the user hitting the enter key. I was
hoping I could just use set but it doesn't look like that's working.

BTW, I meant double quotes and not single quotes as above.

sai

unread,
Apr 16, 2008, 10:02:55 PM4/16/08
to Watir General
Once you enter the text, set the focus on the edit box and use the
AutoIT API to simulate the enter key directly. That should be possible
easier.
Reply all
Reply to author
Forward
0 new messages