Could anybody help with the code below in Ruby / watir??

require ‘watir’

ie = Watir::IE.start(“http://manymoandzo/cgi-bin/arp3/arp3.pl”)

ie.text_field(:name, “name”).set(“user id”)

ie.form(:name, “form”).submit

ie =
Watir::IE.start(“http://manymoandzo/cgi-bin/arp3/arp3.pl?a0=aut&a1=edi&a2=edi&mid=20”)

$Path = “c:\test.htm” ie.text_field(:name,‘html_text’).set($Path)

what I am struggling with is to insert whole content in test.htm to the
field ‘html_text’ in the web site…

this ‘html_text’ field is a big field, and I need to copy what is in
test.htm into ‘html_text’ field using watir… I have about 600 of
these files… which i would like to accomplish using watir…

but it never works out… it is just writing… c:\test.htm in
‘html_text’ field, and what I want this watir program to do is to write
the text inside test.htm file in to the text_field, html_text.

i struggled so many hours… and any help will be greatly appreciated.

thanks.

troubled michael…

Well, what you’re doing is just taking the contents of the variable
$Path and setting it to the text field. You’ll actually need to open and read the file. For example… ie.text_field(:name, “html_text”).set(File.new($Path).read)

That should do it.

M.T.

Matt…

Thanks you so much… It works beautifully…

Now as I have stated in my previous posting, I have many hundreds of

the files are named as email1guide.htm, email2guide.htm…
email3guide.htm… and so on… like this…

Would you please tell me the way to iterate these postings in one
setting rather than doing one by one a couple of hundreds times??

thanks.

grateful, michael

If you mean looping through them all, then you could just wrap it all
up in a little iteration block, like so:

1.upto(number_of_emails) do |num|

use \$Path = “c:\path\to\email#{num}guide.htm” to set the right name

end

Check out the documentation for Int and other enumerables if you’re
confused.

http://rubycentral.com/ref/ref_c_integer.html#upto

If you’ve not purchased it yet, do get Programming Ruby from the
Pragmatic Programmers. It’s the definitive reference and learning
resource for Ruby. Plus, if you’re feeling spunky enough, read _Why
The Lucky Stiff’s Poignant Guide, http://www.poignantguide.net/ which
is a bit wacky, but is still an excellent introduction to the
language.

M.T.

Matt…

Watir??

thanks.

michael

michael wrote:

Matt…

Thanks you so much… It works beautifully…

Now as I have stated in my previous posting, I have many hundreds of

the files are named as email1guide.htm, email2guide.htm…
email3guide.htm… and so on… like this…

Would you please tell me the way to iterate these postings in one
setting rather than doing one by one a couple of hundreds times??

thanks.

grateful, michael

#-- assuming all files you want to find start with “email” and have
#-- an “.htm” extension
files = Dir.glob(“email*.htm”)

#-- interate thru list of files
files.each {|file|

#-- this is where you’d do what you need with the file, for now
#-- we’re just displaying the name of the file
puts(file)

}

first of all, thank you for the suggestion…

now what if I wish to save the file in C:\ directory, with the file
name of 1.htm…

how do I change the code you have suggested?? what change do I make to
the code to save it as c:\1.htm??

thanks.

michael…

first of all, thank you for the suggestion…

now what if I wish to save the file in C:\ directory, with the file
name of 1.htm…

how do I change the code you have suggested?? what change do I make to
the code to save it as c:\1.htm??

thanks.

michael…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.