Class: BrowserShooter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/browser_shooter/base.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Base

Returns a new instance of Base.



5
6
7
# File 'lib/browser_shooter/base.rb', line 5

def initialize( opts )
  @opts = opts
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



3
4
5
# File 'lib/browser_shooter/base.rb', line 3

def opts
  @opts
end

Class Method Details

.run_test(suite, test, browser, output_path) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/browser_shooter/base.rb', line 34

def self.run_test( suite, test, browser, output_path )
  BrowserShooter::Logger.log( "Executing #{suite.name} | #{test.name} | #{browser.name}", true )
  output_path = "#{output_path}/#{suite.name}/#{test.name}/#{browser.name}"

  driver = nil

  begin
    driver =
      Selenium::WebDriver.for(
        :remote,
        :url => browser.url,
        :desired_capabilities => browser.type.to_sym
      )

    driver.manage.timeouts.implicit_wait = 40

    logs =
      BrowserShooter::Commander.script(
        test.commands,
        driver,
        browser,
        output_path
      )

    BrowserShooter::LogExporter.export(
      logs,
      "#{output_path}/logs"
    )

  ensure
    driver.quit if driver
  end
end

Instance Method Details

#runObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/browser_shooter/base.rb', line 9

def run
  BrowserShooter::Logger.verbose = opts[:verbose]
  BrowserShooter::Logger.log( "Starting script running with version #{BrowserShooter::VERSION}..." )

  config = BrowserShooter::Configurator.new( opts )
  suites = config.suites

  suites.each do |suite|
    suite.tests.each do |test|
      suite.browsers.each do |browser|
        BrowserShooter::Base.run_test(
          suite,
          test,
          browser,
          config["output_path"]
        )
      end
    end
  end

  BrowserShooter::Logger.log( "... script running ended." )
  BrowserShooter::Logger.log( "Logs and Shots are in: #{config["output_path"]}", true )
  BrowserShooter::Logger.log( "BYE!" )
end