私はgoogleに行く簡単なwatir(web-driver)スクリプトを持っています。しかし、私はオプションのパーサを使用して、ブラウザでcmdを選択する引数を設定したいと思います。以下は私のスクリプトです:Firefoxの-f DOC --browser RSpecのietest.rbを実行OptionParserとrspecを使用できません
require 'optparse'
require 'commandline/optionparser'
include CommandLine
require 'watir-webdriver'
describe 'Test google website' do
before :all do
options = {}
opts = OptionParser.new do |opts|
opts.on("--browser N",
"Browser to execute test scripts") do |n|
options[:browser] = n
$b = n.to_s
end
end
opts.parse! ARGV
p options
end
describe 'The test website should be displayed' do
it 'should go to google' do
$ie = Watir::Browser.new($b)
#go to test website
$ie.goto("www.google.com")
end
end
end
はちょうど私に無効なオプションを与える、ietestは私のファイルの名前です。スクリプトコードを変更することなく、Webドライバを使用してブラウザを設定する他の直観的な方法も歓迎します。
情報をありがとう! – Sun