我是瓦蒂尔的新手。当我在终端ruby TestJoinChange.rb中运行此文件时,我得到NoMethodError
require 'rubygems'
require 'test/unit'
require 'watir-webdriver'
browser = Watir::Browser.new
class TestJoinChange < Test::TestCase
def test_join(logintype,usr,pwd)
# open browser to page
@browser.goto 'http://change.com'
end
end
如何传递参数值?为什么我的函数不返回方法错误?
"您已经定义了子例程,现在您可以通过创建类的对象在调用该子例程时传递值。
您的代码:
require 'rubygems'
require 'test/unit'
require 'watir-webdriver'
browser = Watir::Browser.new
class TestJoinChange < Test::TestCase
def test_join(logintype,usr,pwd)
# open browser to page
@browser.goto 'http://change.com'
end
end
现在只需为您的类创建一个对象:
obj = TestJoinChange.new
# it will create object for your class and now call the subroutine and pass any value in that#
obj.test_join("logintype_value", "user", "password")
现在,您可以通过将所有传递的值存储在变量中来使用类中的值。