Class: SeleniumConnect::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium_connect/job.rb

Overview

encapsulates the creation of a driver and a run

Instance Method Summary collapse

Constructor Details

#initialize(config, report_factory, sauce_facade) ⇒ Job

Returns a new instance of Job.



14
15
16
17
18
# File 'lib/selenium_connect/job.rb', line 14

def initialize(config, report_factory, sauce_facade)
  @config = config
  @report_factory = report_factory
  @sauce_facade = sauce_facade
end

Instance Method Details

#finish(opts = {}) ⇒ Object

Finishes the driver run, taking any data to help, returning report



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/selenium_connect/job.rb', line 29

def finish(opts = {})

  # extracted from the earlier main finish
  begin
    @driver.quit
    @data = { assets: {} }
    process_sauce_logs(opts) if @config.host == 'saucelabs'
  # rubocop:disable HandleExceptions
  rescue Selenium::WebDriver::Error::WebDriverError
  # rubocop:enable HandleExceptions
  end
  @report_factory.build :job, @data
end

#start(opts = {}) ⇒ Object

Creates and returns the driver, using options passed in



21
22
23
24
25
26
# File 'lib/selenium_connect/job.rb', line 21

def start(opts = {})
  @job_name = slugify_name opts[:name] if opts.has_key? :name
  # TODO this could be refactored out into an options parser of sorts
  @config.sauce_opts.job_name = @job_name ||= 'unnamed_job'
  @driver = Runner.new(@config).driver
end