Class: Popart::Browser

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(capabilities) ⇒ Browser

Returns a new instance of Browser.



7
8
9
# File 'lib/popart/browser.rb', line 7

def initialize capabilities
  @capabilities = capabilities
end

Instance Attribute Details

#capabilitiesObject (readonly)

Returns the value of attribute capabilities.



5
6
7
# File 'lib/popart/browser.rb', line 5

def capabilities
  @capabilities
end

Instance Method Details

#cleanupObject



31
32
33
34
35
36
# File 'lib/popart/browser.rb', line 31

def cleanup
  @browser.quit if @browser
rescue
ensure
  @browser = nil
end

#filenameObject



24
25
26
27
28
29
# File 'lib/popart/browser.rb', line 24

def filename
  filename = capabilities["browserName"] + '_' + capabilities["version"] + '_' + capabilities["platform"] + '.png'
  filename.gsub! " ", "-"

  filename
end

#perform(&block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/popart/browser.rb', line 11

def perform &block
  unless @browser
    @browser = SeleniumSession.new capabilities

    begin
      yield @browser
    rescue

      # TODO SOMETHING LESS CRAP HERE
    end
  end
end