Class: Crabfarm::PhantomDriverFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/crabfarm/phantom_driver_factory.rb

Instance Method Summary collapse

Constructor Details

#initialize(_phantom, _config = {}) ⇒ PhantomDriverFactory

Returns a new instance of PhantomDriverFactory.



4
5
6
7
# File 'lib/crabfarm/phantom_driver_factory.rb', line 4

def initialize(_phantom, _config={})
  @phantom = _phantom
  @config = _config
end

Instance Method Details

#build_driver(_session_id) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/crabfarm/phantom_driver_factory.rb', line 9

def build_driver(_session_id)

  # setup a custom client to use longer timeouts
  client = Selenium::WebDriver::Remote::Http::Default.new
  client.timeout = @config[:remote_timeout]

  driver = Selenium::WebDriver.for :remote, {
    :url => phantom_url,
    :http_client => client,
    :desired_capabilities => @config[:capabilities]
  }

  driver.send(:bridge).setWindowSize(@config[:window_width], @config[:window_height])

  return driver
end