Class: Billy::Browsers::Capybara
- Inherits:
-
Object
- Object
- Billy::Browsers::Capybara
- Defined in:
- lib/billy/browsers/capybara.rb
Constant Summary collapse
- DRIVERS =
{ poltergeist: 'capybara/poltergeist', webkit: 'capybara/webkit', selenium: 'selenium/webdriver', apparition: 'capybara/apparition', cuprite: 'capybara/cuprite' }
Class Method Summary collapse
- .build_selenium_options_for_firefox ⇒ Object
- .register_apparition_driver ⇒ Object
- .register_cuprite_driver ⇒ Object
- .register_drivers ⇒ Object
- .register_poltergeist_driver ⇒ Object
- .register_selenium_driver ⇒ Object
- .register_webkit_driver ⇒ Object
Class Method Details
.build_selenium_options_for_firefox ⇒ Object
119 120 121 122 123 124 125 126 127 |
# File 'lib/billy/browsers/capybara.rb', line 119 def self. profile = Selenium::WebDriver::Firefox::Profile.new.tap do |prof| prof.proxy = Selenium::WebDriver::Proxy.new( http: "#{Billy.proxy.host}:#{Billy.proxy.port}", ssl: "#{Billy.proxy.host}:#{Billy.proxy.port}") end Selenium::WebDriver::Firefox::Options.new(profile: profile) end |
.register_apparition_driver ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/billy/browsers/capybara.rb', line 97 def self.register_apparition_driver ::.register_driver :apparition_billy do |app| ::::Apparition::Driver.new(app, ignore_https_errors: true).tap do |driver| driver.set_proxy(Billy.proxy.host, Billy.proxy.port) end end end |
.register_cuprite_driver ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/billy/browsers/capybara.rb', line 105 def self.register_cuprite_driver = { browser_options: { 'ignore-certificate-errors' => nil } }.deep_merge(Billy.config.) ::.register_driver :cuprite_billy do |app| ::::Cuprite::Driver.new(app, **).tap do |driver| driver.set_proxy(Billy.proxy.host, Billy.proxy.port) end end end |
.register_drivers ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/billy/browsers/capybara.rb', line 15 def self.register_drivers DRIVERS.each do |name, driver| begin require driver send("register_#{name}_driver") rescue LoadError end end end |
.register_poltergeist_driver ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/billy/browsers/capybara.rb', line 27 def self.register_poltergeist_driver ::.register_driver :poltergeist_billy do |app| = { phantomjs_options: [ '--ignore-ssl-errors=yes', "--proxy=#{Billy.proxy.host}:#{Billy.proxy.port}" ] } ::::Poltergeist::Driver.new(app, ) end end |
.register_selenium_driver ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/billy/browsers/capybara.rb', line 49 def self.register_selenium_driver ::.register_driver :selenium_billy do |app| = ::::Selenium::Driver.new(app, options: ) end ::.register_driver :selenium_headless_billy do |app| = .tap do |opts| opts.add_argument '-headless' end ::::Selenium::Driver.new(app, options: ) end ::.register_driver :selenium_chrome_billy do |app| = Selenium::WebDriver::Chrome::Options.new .add_argument('--ignore-certificate-errors') .add_argument("--proxy-server=#{Billy.proxy.host}:#{Billy.proxy.port}") ::::Selenium::Driver.new( app, browser: :chrome, options: , clear_local_storage: true, clear_session_storage: true ) end ::.register_driver :selenium_chrome_headless_billy do |app| = Selenium::WebDriver::Chrome::Options.new .add_argument('--headless=new') .add_argument('--enable-features=NetworkService,NetworkServiceInProcess') .add_argument('--ignore-certificate-errors') .add_argument("--proxy-server=#{Billy.proxy.host}:#{Billy.proxy.port}") .add_argument('--disable-gpu') if Gem.win_platform? .add_argument('--no-sandbox') if ENV['CI'] ::::Selenium::Driver.new( app, browser: :chrome, options: , clear_local_storage: true, clear_session_storage: true ) end end |
.register_webkit_driver ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/billy/browsers/capybara.rb', line 39 def self.register_webkit_driver ::.register_driver :webkit_billy do |app| = { ignore_ssl_errors: true, proxy: {host: Billy.proxy.host, port: Billy.proxy.port} } ::::Webkit::Driver.new(app, ::::Webkit::Configuration.to_hash.merge()) end end |