From: Siep Korteling Date: 2008-01-24T07:35:46+09:00 Subject: Re: using ruby to validate web pages lrlebron@gmail.com wrote: > On Jan 18, 8:54 am, Kate Bond wrote: >> url1 = "http://www.google.com" >> ie.text_field(:id, "uri").set(url1) >> end >> puts "URL#2 validates!" >> >> >> I get results for URL's #2 and #3, only the 'Checking URL....' and 'End >> of validation' messages. > > Your are missing the "puts" before the "URL # does not validate" If you had 200 pages to validate, you'd have to correct 200 lines of code. Consider this (untested, I don't know Watir): require 'watir' # set variables validator = "http://validator.w3.org/" urls =[] urls << "http://www.google.com" urls << "http://pingmag.jp/2008/01/17/chimpom/" urls << "http://www.google.com/" # open the IE browser ie = Watir::IE.new puts "Beginning validation" ie.goto validator # maybe this should be in the block. urls.each do|url| puts "Checking " + url ie.text_field(:id, "uri").set(url) ie.button(:value, "Check").click if ie.text.include? "This Page Is Valid" puts url + " validates!" else url + " does not validate!" #!! This line needs a 'puts' !! end end ie.close #or something like it puts "End of validation" Both the the list of urls and the code handling this list are now much easier to maintain. Regards, Siep -- Posted via http://www.ruby-forum.com/.