lib/quke/driver_configuration.rb in quke-0.3.0 vs lib/quke/driver_configuration.rb in quke-0.3.1
- old
+ new
@@ -46,10 +46,12 @@
# initialised with
#
# Capybara::Poltergeist::Driver.new(app, my_driver_config.poltergeist)
#
def poltergeist
+ # The arguments we can pass to poltergeist are documented here
+ # https://github.com/teampoltergeist/poltergeist#customization
{
# Javascript errors will get re-raised in our tests causing them to fail
js_errors: true,
# How long in seconds we'll wait for response when communicating with
# Phantomjs
@@ -97,18 +99,21 @@
# inspector: true
# }
# )
#
def phantomjs
+ # For future reference the options we pass through to phantomjs appear to
+ # mirror those you can actually supply on the command line.
+ # http://phantomjs.org/api/command-line.html
options = [
'--load-images=no',
'--disk-cache=false',
'--ignore-ssl-errors=yes'
]
- if config.use_proxy?
- options.push("--proxy=#{config.proxy['host']}:#{config.proxy['port']}")
- end
+
+ options.push("--proxy=#{config.proxy['host']}:#{config.proxy['port']}") if config.use_proxy?
+
options
end
# Returns an array to be used in conjunction with the +:switches+ argument
# when initialising a Capybara::Selenium::Driver set for Chrome.
@@ -118,11 +123,12 @@
# Capybara::Selenium::Driver.new(
# app,
# browser: :chrome,
# switches: [
# "--proxy-server=localhost:8080",
- # "--proxy-bypass-list=127.0.0.1,192.168.0.1"
+ # "--proxy-bypass-list=127.0.0.1,192.168.0.1",
+ # "--user-agent=Mozilla/5.0 (MSIE 10.0; Windows NT 6.1; Trident/5.0)"
# ]
# )
#
# Rather than setting the switches manually Quke::DriverConfiguration.chrome
# is intended to manage what they should be based on the properties of the
@@ -143,10 +149,12 @@
no_proxy = config.proxy['no_proxy'].tr(',', ';')
result.push("--proxy-server=#{host}:#{port}") if config.use_proxy?
result.push("--proxy-bypass-list=#{no_proxy}") unless config.proxy['no_proxy'].empty?
+ result.push("--user-agent=#{config.user_agent}") unless config.user_agent.empty?
+
result
end
# rubocop:enable Metrics/AbcSize
# Returns an instance of Selenium::WebDriver::Remote::Capabilities to be
@@ -158,10 +166,11 @@
# my_profile = Selenium::WebDriver::Firefox::Profile.new
# my_profile.proxy = Selenium::WebDriver::Proxy.new(
# http: "10.10.2.70:8080",
# ssl: "10.10.2.70:8080"
# )
+ # my_profile['general.useragent.override'] = "Mozilla/5.0 (MSIE 10.0; Windows NT 6.1; Trident/5.0)"
# Capybara::Selenium::Driver.new(
# app,
# profile: my_profile
# )
#
@@ -178,18 +187,17 @@
# rubocop:disable Metrics/AbcSize
def firefox
profile = Selenium::WebDriver::Firefox::Profile.new
settings = {}
- host = config.proxy['host']
- port = config.proxy['port']
- no_proxy = config.proxy['no_proxy']
- settings[:http] = "#{host}:#{port}" if config.use_proxy?
+ settings[:http] = "#{config.proxy['host']}:#{config.proxy['port']}" if config.use_proxy?
settings[:ssl] = settings[:http] if config.use_proxy?
- settings[:no_proxy] = no_proxy unless config.proxy['no_proxy'].empty?
+ settings[:no_proxy] = config.proxy['no_proxy'] unless config.proxy['no_proxy'].empty?
profile.proxy = Selenium::WebDriver::Proxy.new(settings) if config.use_proxy?
+
+ profile['general.useragent.override'] = config.user_agent unless config.user_agent.empty?
profile
end
# rubocop:enable Metrics/AbcSize