DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Test If Sites Are Online

08.24.2006
| 3475 views |
  • submit to reddit
        // test if sites are online by title validation
// if the title can change, test can validate occurance of a phrase instead

require 'rwebunit'  # ruby web test based on watir (uses ie=internet-explorer-object)

# test if sites are online by title validation
# usage: to run this test without visible ie use the -b option
# C:\ruby\workspace\ruject1>ruby rwu_site_checker.rb -b

class RwuSiteChecker < RWebUnit::WebTestCase

  # hash with url and title
  @@sites = {
    "http://www.domain_number_one.de" => "title number one",
    "http://www.seccond_domain.org" => "seccond title",
    "http://www.yet_another_domain.com" => "yet another title"
  }
  
  # test for titles
  def test_titles()
    log = "testing title \n"
    @@sites.each { |url, title|
      getTestContext().base_url=url
      beginAt("/")
      assertTitleEquals(title)
      # to check for phrase: assertTextPresent(phrase) 
   
      log += url + " ok \n"
    }
    puts log
  end
  
end

    

Comments

Terry Donaghe replied on Fri, 2006/08/25 - 2:42pm

Oh no! I posted the above comment in the wrong place! Can some kind admin please remove this comment and my other comment above? Thanks!

Terry Donaghe replied on Fri, 2006/08/25 - 2:42pm

For more information about this snippet, please see my post at Rubynoob.com http://www.rubynoob.com/articles/2006/08/23/how-to-use-the-flickr-api-with-a-simple-ruby-script