我将不胜感激帮助对以下代码中的错误进行排序:
require 'rubygems'
require 'watir'
require 'watir-webdriver'
require 'test/unit'
class TestGoogle < Test::Unit::TestCase
def setup
@browser = Watir::Browser.new :firefox
end
def testSignInLink
@browser.goto "http://google.com/"
po = PageObjects.new(@browser)
po.clickLinkSignIn
end
end
class PageObjects
def initialize( browser )
@browser = browser
end
def clickLinkSignIn()
@browser.link(:id, "gb_70").click
end
end
tg = TestGoogle.new
tg.setup
tg.testSignInLink
错误是:
Uncaught exception: wrong number of arguments (0 for 1)
C:/Ruby193/lib/ruby/1.9.1/minitest/unit.rb:971:in `initialize'
C:/RubymineProjects/ditto/Google_01_TU_02.rb:28:in `new'
C:/RubymineProjects/ditto/Google_01_TU_02.rb:28:in `<top (required)>'
第 28 行是:
tg = TestGoogle.new
奇怪的是,该脚本随后运行完成,并显示了谷歌登录页面。
请注意,还没有断言——我一次只做一小步。
编辑后添加:
C:/Ruby193/lib/ruby/1.9.1/minitest/unit.rb:971 中的初始化程序
def initialize name # :nodoc:
@__name__ = name
@__io__ = nil
@passed = nil
end