Forum: Ruby I want to automate this text field.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Asha L. (Guest)
on 2009-04-29 08:21
Hi

I want to automate this text field.

ie.text_field(:name, "JMSText").set('TEST').

Instead of TEST i want to copy content from text file and paste it in
text filed.

if i change the text in notepad ..it shoudl take the new value

Pleae help regarding this


Regards
Asha
Suraj K. (Guest)
on 2009-04-29 08:38
Asha Latha wrote:
> ie.text_field(:name, "JMSText").set('TEST').
>
> Instead of TEST i want to copy content from text file and paste it in
> text filed.

Use the File::read() method:

  file_path = "path to your file.txt"

  file_contents = File.read(file_path)

  ie.text_field(:name, "JMSText").set(file_contents)

> if i change the text in notepad ..it shoudl take the new value

With the above approach, you must rerun your Ruby program after changing
the text in notepad.

If you wish to have your Ruby program respond to changes in the text
file while it is still running, then take a look at libinotify.
Asha L. (Guest)
on 2009-04-29 09:37
Hi

Thanks its working.

But i want to read first line and then paste that one to text filed,
once it is done i will read second line and so on....

Please help me to solve this.

Regards
Asha


Suraj K. wrote:
> Asha Latha wrote:
>> ie.text_field(:name, "JMSText").set('TEST').
>>
>> Instead of TEST i want to copy content from text file and paste it in
>> text filed.
>
> Use the File::read() method:
>
>   file_path = "path to your file.txt"
>
>   file_contents = File.read(file_path)
>
>   ie.text_field(:name, "JMSText").set(file_contents)
>
>> if i change the text in notepad ..it shoudl take the new value
>
> With the above approach, you must rerun your Ruby program after changing
> the text in notepad.
>
> If you wish to have your Ruby program respond to changes in the text
> file while it is still running, then take a look at libinotify.
7stud -. (Guest)
on 2009-04-29 10:15
Asha Latha wrote:
> Hi
>
> Thanks its working.
>
> But i want to read first line and then paste that one to text filed,
> once it is done i will read second line and so on....
>
> Please help me to solve this.
>
> Regards
> Asha
>
>

IO.foreach("file_name") do |line|
   ...stuff here
end
This topic is locked and can not be replied to.