curious wrote:
<snip>
> I need to make the WATIR code read each line in C:\text.txt file one by
> one 10 times. Could anyone tell me how I should adjust the code above
> so that this WATIR code read each line in C:\text.txt file one by one
> ten times, and process each time with the value in each line in the
> text file??
Watir has very little to with it, you've already got the code to
populate the textbox and click the "Submit" button. The question is how
do you open a file and read each line. The following should do it.
file = File.open("c:/text.txt", "r")
lines = file.readlines()
#-- make 10-passes thru this loop
1.upto(10) {
#-- process each element in the array
0.upto(lines.length - 1) {|j|
ie.text_field(:name, "info").set(lines[j])
ie.button(:value, "Submit").click
}
}
file.close()
lines.clear()
--
Posted via
http://www.ruby-forum.com/.