Hey B! Just a few things. First off, there is a more efficient way of opening a file for writing. Try the following instead:
textlog = File.open("text.log", "w") Secondly, when I run your script, the text.log file is *not* empty. There are in fact 70 blank lines in the output file. That tells me something. It tells me that you are correctly opening and writing to the file, but you just aren't capturing the right information somewhere. I replaced your link iteration with the following and I got the log file to list all the URL's: ie.links.each do |link| textlog.puts link.href end Is that what you wanted to do? If not, please post some more details with what you are looking for and we'll try to help. Cheers! Paul C. On 14/06/07, B Smith <[EMAIL PROTECTED]> wrote:
I am very close, this finds the links but errors on a variable and the .txt file is empty #-------------------------------------------------------------------------------------------------------------# # # I'm a Pretty Flower Box # # # #------------------------------------------------------------------------------------------------------------# require 'watir' # the watir controller # set a variable test_site = 'http://www.google.com' # set the log file textlog = File.open("text.log", File::CREAT|File::APPEND|File::WRONLY) # open the IE browser ie = Watir::IE.new # print some comments puts "## Beginning of test: Google search" puts " " ie.goto(test_site) puts " Action: entered " + test_site + " in the address bar." ie.text_field(:name, "q").set("Beer + Bottle + Label") # q is the name of the search field puts "Step 3: click the 'Google Search' button" ie.button(:name, "btnG").click # "btnG" is the name of the Search button puts " Action: clicked the Google Search button." puts "Expected Result: " puts " - a Google page with results should be shown." puts "Iterate thru links on page a pull them into txt file " puts "Test Passed. Found the test string: 'Beer Bottle Label'." ie.links.each do |link| # for each link on the current page in IE... textlog.puts link.src # print url of the link in the textlog we created end # createdtextlog.puts "Here's some stuff" puts "## End of test: Google search" if ie.contains_text("Beer + Bottle + Label") else puts "Test Failed!" end _______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general