Class: Popart::SeleniumSession

Inherits:
Object
  • Object
show all
Defined in:
lib/popart/selenium_session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(desired_capabilities) ⇒ SeleniumSession

Returns a new instance of SeleniumSession.



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/popart/selenium_session.rb', line 32

def initialize desired_capabilities
  @driver = Selenium::WebDriver.for :remote, :url => endpoint,  :desired_capabilities => desired_capabilities

  at_exit do
    if @driver
      begin
        @driver.quit
      rescue
        #Not relevant anymore
      end
    end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/popart/selenium_session.rb', line 46

def method_missing m, *args
  if !args.empty?
    @driver.send(m, *args)
  else
    @driver.send(m)
  end
end

Instance Attribute Details

#driverObject (readonly)

Returns the value of attribute driver.



6
7
8
# File 'lib/popart/selenium_session.rb', line 6

def driver
  @driver
end

Instance Method Details

#authObject



16
17
18
# File 'lib/popart/selenium_session.rb', line 16

def auth
  "#{un}:#{pw}"
end

#endpointObject



28
29
30
# File 'lib/popart/selenium_session.rb', line 28

def endpoint
  "http://#{auth}@#{server}:#{port}/wd/hub"
end

#portObject



24
25
26
# File 'lib/popart/selenium_session.rb', line 24

def port
  80
end

#pwObject



12
13
14
# File 'lib/popart/selenium_session.rb', line 12

def pw
  ENV["SAUCE_ACCESS_KEY"]
end

#serverObject



20
21
22
# File 'lib/popart/selenium_session.rb', line 20

def server
  "ondemand.saucelabs.com"
end

#unObject



8
9
10
# File 'lib/popart/selenium_session.rb', line 8

def un
  ENV["SAUCE_USERNAME"]
end