class Crabfarm::Adapters::Browser::PhantomJs

Public Instance Methods

cleanup_driver_services() click to toggle source
# File lib/crabfarm/adapters/browser/phantom_js.rb, line 14
def cleanup_driver_services
  @phantom.stop unless @phantom.nil?
  @phantom = nil
end
prepare_driver_services() click to toggle source
# File lib/crabfarm/adapters/browser/phantom_js.rb, line 10
def prepare_driver_services
  @phantom = load_and_start_phantom if @phantom.nil?
end

Private Instance Methods

build_webdriver_instance() click to toggle source
# File lib/crabfarm/adapters/browser/phantom_js.rb, line 21
def build_webdriver_instance
  Support::WebdriverFactory.build_remote_driver driver_config
end
driver_config() click to toggle source
# File lib/crabfarm/adapters/browser/phantom_js.rb, line 46
def driver_config
  config.merge({
    remote_host: phantom_url,
    proxy: nil
  })
end
load_and_start_phantom() click to toggle source
# File lib/crabfarm/adapters/browser/phantom_js.rb, line 25
def load_and_start_phantom
  new_phantom = Support::PhantomRunner.new phantom_config
  new_phantom.start
  return new_phantom
end
phantom_config() click to toggle source
# File lib/crabfarm/adapters/browser/phantom_js.rb, line 31
def phantom_config
  {
    load_images: Crabfarm.config.phantom_load_images,
    log_level: Crabfarm.config.phantom_log_level,
    ssl: Crabfarm.config.phantom_ssl,
    bin_path: Crabfarm.config.phantom_bin_path,
    proxy: config[:proxy],
    port: Utils::PortDiscovery.find_available_port
  }
end
phantom_url() click to toggle source
# File lib/crabfarm/adapters/browser/phantom_js.rb, line 42
def phantom_url
  "http://localhost:#{@phantom.port}"
end