Home | Mirror | Search

第 6 章 Selenium - Web Browser Automation

目錄

1. ruby
1.1. ruby example
2. python
2.1. python example
3. Selenium RC

http://selenium.seleniumhq.org/

1. ruby

gem install selenium-webdriver
		

1.1. ruby example

例 6.1. ruby testcase

				
require "selenium"
require "test/unit"

class NewTest < Test::Unit::TestCase
  def setup
    @verification_errors = []
    if $selenium
      @selenium = $selenium
    else
      @selenium = Selenium::SeleniumDriver.new("192.168.1.3", 5555, "*firefox", "http://www.google.com/", 10000);
      @selenium.start
    end
    @selenium.set_context("test_new")
  end

  def teardown
    @selenium.stop unless $selenium
    assert_equal [], @verification_errors
  end

  def test_new
    @selenium.open "/"
    @selenium.type "q", "selenium rc"
    @selenium.click "btnG"
    @selenium.wait_for_page_to_load "30000"
    assert @selenium.is_text_present("Results * for selenium rc")
  end
end				
				
				

comments powered by Disqus