Class: SeleniumConnect::Job
- Inherits:
-
Object
- Object
- SeleniumConnect::Job
- Defined in:
- lib/selenium_connect/job.rb
Overview
encapsulates the creation of a driver and a run
Instance Method Summary collapse
-
#finish(opts = {}) ⇒ Object
Finishes the driver run, taking any data to help, returning report.
-
#initialize(config, report_factory, sauce_facade) ⇒ Job
constructor
A new instance of Job.
-
#start(opts = {}) ⇒ Object
Creates and returns the driver, using options passed in.
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
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/selenium_connect/job.rb', line 32 def finish(opts = {}) # extracted from the earlier main finish begin save_html if opts.key?(:failshot) && opts[:failshot] && @config.host != 'saucelabs' save_screenshot end @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 27 28 29 |
# File 'lib/selenium_connect/job.rb', line 21 def start(opts = {}) # TODO: this could be refactored out into an options parser of sorts @job_name = opts.key?(:name) ? slugify_name(opts[:name]) : 'unnamed_job' sauce_config = {} sauce_config.merge!(opts[:sauce_opts]) if opts.key? :sauce_opts sauce_config.merge!(job_name: @job_name) @config.sauce_opts = sauce_config @driver = Runner.new(@config).driver end |