Skip to content

Instantly share code, notes, and snippets.

@indare
Last active August 29, 2015 14:13
Show Gist options
  • Save indare/a51554de3f36f77fdf30 to your computer and use it in GitHub Desktop.
Save indare/a51554de3f36f77fdf30 to your computer and use it in GitHub Desktop.
Capybara + PhantomJS + WebDriver
Capybara.app = 'https://at2.admin.fortunemusic.jp'
Capybara.app_host = 'https://at2.admin.fortunemusic.jp'
Capybara.run_server = false
Capybara.register_driver :poltergeist do |app|
options = {
debug: false,
js_errors: false,
inspector: true,
timeout: 20,
phantomjs_options: %w(--ignore-ssl-errors=yes --web-security=no)
}
if ENV['http_proxy']
options[:phantomjs_options].push('--proxy=' + ENV['http_proxy'])
end
Capybara::Poltergeist::Driver.new(app, options)
end
Capybara.register_driver :selenium_proxy do |app|
profile = Selenium::WebDriver::Firefox::Profile.new
if ENV['http_proxy']
proxy = URI.parse(ENV['http_proxy'])
profile["network.proxy.type"] = 1 # manual proxy config
profile["network.proxy.http"] = proxy.host
profile["network.proxy.http_port"] = proxy.port
profile["network.proxy.ssl"] = proxy.host
profile["network.proxy.ssl_port"] = proxy.port
profile["network.proxy.no_proxies_on"] = "localhost,127.0.0.1"
end
Capybara::Selenium::Driver.new(app, :profile => profile)
end
Capybara.default_driver = :poltergeist
Capybara.javascript_driver = :poltergeist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment