Class: Rubium::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/rubium/session.rb

Defined Under Namespace

Classes: ConnectionError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, capabilities, timeout = 30) ⇒ Session

Returns a new instance of Session.


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rubium/session.rb', line 7

def initialize(host, port, capabilities, timeout = 30)
  client = Selenium::WebDriver::Remote::Http::Default.new
  client.timeout = timeout

  @driver = Selenium::WebDriver.for(:remote,
    desired_capabilities: capabilities.to_hash,
    url: "http://#{host}:#{port}#{Rubium.root_path}",
    http_client: client
  )
rescue Errno::ECONNREFUSED
  raise ConnectionError
end

Instance Attribute Details

#drivervoid (readonly)

Returns the value of attribute driver


5
6
7
# File 'lib/rubium/session.rb', line 5

def driver
  @driver
end

Instance Method Details

#terminatevoid


20
21
22
# File 'lib/rubium/session.rb', line 20

def terminate
  @driver.quit rescue nil
end