我需要讓我的webdriver測試命中多個服務器。我的解決方案是在一個命令行參數來傳遞,但是當運行下面使用optparse在ruby測試中爲webdriver設置目標服務器
紅寶石的webdriver/E2E/*。RB -s =本地主機
或
紅寶石的webdriver代碼/e2e/*.rb --server = localhost
但我得到以下錯誤。我收到以下錯誤
C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:49:in `process_args': invalid argument: -s=localhost (OptionParser::InvalidArgument)
from C:/Ruby193/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
from C:/Ruby193/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
from C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:21:in `run'
from C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
from C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
from C:/Ruby193/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'
test.rb
require 'test/unit'
require 'optparse'
class SuperTestClass < Test::Unit::TestCase
def setup
@server = "https://localhost/"
optparse = OptionParser.new do|opts|
opts.on('-s', '--server server', 'Server to run tests against') do|server|
@server = server
end
end
...
end
...
end
UPDATE
我改變
opts.on('-s', '--server server', 'Server to run tests against') do|server|
到
opts.on('-serv', '--server server', 'Server to run tests against') do|server|
,但它並沒有解決它