我正在尝试将一些其他选项传递给Selenium Web驱动程序,以便使用Teaspoon运行JavaScript测试。我无法识别opts
。
我的配置代码:
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 180 # 3 mins instead of the default 60 seconds
config.driver_options = HashWithIndifferentAccess.new(client_driver: [:firefox, {http_client: client}])
鉴于使用我的配置选项的库代码:
driver = ::Selenium::WebDriver.for(driver_options[:client_driver])
其中::Selenium::WebDriver.for
函数定义为:
def self.for(*args)
WebDriver::Driver.for(*args)
end
其中WebDriver::Driver.for
定义为:
def for(browser, opts = {})
listener = opts.delete(:listener)
bridge = case browser
when :firefox, :ff
Firefox::Bridge.new(opts)
when :remote
Remote::Bridge.new(opts)
when :ie, :internet_explorer
IE::Bridge.new(opts)
when :chrome
Chrome::Bridge.new(opts)
when :android
Android::Bridge.new(opts)
when :iphone
IPhone::Bridge.new(opts)
when :opera
Opera::Bridge.new(opts)
when :phantomjs
PhantomJS::Bridge.new(opts)
when :safari
Safari::Bridge.new(opts)
else
raise ArgumentError, "unknown driver: #{browser.inspect}"
end
bridge = Support::EventFiringBridge.new(bridge, listener) if listener
new(bridge)
end
如何为(string, hash)
传递(browser, opts)
?通过我的尝试,整个哈希[:firefox, {http_client: client}]
被传递到browser
变量。