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, config) ⇒ Object

Runs a single test with all its commands in an specific browser



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
67
68
# File 'lib/browser_shooter/base.rb', line 36

def self.run_test( suite, test, browser, config )
  BrowserShooter::Logger.log( "Executing #{suite.name} | #{test.name} | #{browser.name}", true )
  output_path = "#{config["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 = config["timeout"]

    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

Main method. Loads the configuration, filter the suites, runs the tests and exports the logs.



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

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
        )
      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