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) ⇒ 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) ⇒ Job
Returns a new instance of Job.
15 16 17 18 |
# File 'lib/selenium_connect/job.rb', line 15 def initialize(config, report_factory) @config = config @report_factory = report_factory 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 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/selenium_connect/job.rb', line 29 def finish(opts = {}) # extracted from the earlier main finish begin @driver.quit data = {} if @config.host == 'saucelabs' job_id = @driver.session_id if opts.has_key?(:failed) && opts[:failed] fail_job job_id if opts.has_key?(:failshot) && opts[:failshot] data[:failshot] = save_last_screenshot job_id end end if opts.has_key?(:passed) && opts[:passed] pass_job job_id end data.merge! fetch_logs(job_id) end # rubocop:disable HandleExceptions rescue Selenium::WebDriver::Error::WebDriverError # rubocop:enable HandleExceptions end report_data = symbolize_keys data @report_factory.build :job, report_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 = {}) # TODO this could be refactored out into an options parser of sorts @config.description = opts[:name] if opts.has_key? :name @driver = Runner.new(@config).driver end |