class SeleniumReporter

Constants

VERSION

Attributes

output_dir[R]

Public Class Methods

new() click to toggle source
# File lib/selenium-reporter.rb, line 10
def initialize
  ConfigChecker.new
  make_absolute ENV['SE_OUTPUT_DIR']
  System::Folder.prepare
  load_rspec_config
end

Public Instance Methods

generate_report() click to toggle source
# File lib/selenium-reporter.rb, line 21
def generate_report
  system("java -jar #{allure_cli} generate #{xml_dir} -o #{report_dir}")
end
screenshot_file() click to toggle source
# File lib/selenium-reporter.rb, line 17
def screenshot_file
  "#{screenshot_dir}/#{UUID.new.generate}.png"
end
serve_report() click to toggle source
# File lib/selenium-reporter.rb, line 25
def serve_report
  ENV['SE_REPORT_DIR'] = report_dir
  @pid = Process.spawn('ruby lib/selenium-reporter/report-server.rb')
end
stop_report() click to toggle source
# File lib/selenium-reporter.rb, line 30
def stop_report
  Process.kill("KILL", @pid)
  ENV['SE_REPORT_DIR'] = nil
end

Private Instance Methods

allure_cli() click to toggle source
# File lib/selenium-reporter.rb, line 58
def allure_cli
  File.join(pwd, 'bin/allure/allure-cli-2.1.jar')
end
load_rspec_config() click to toggle source
# File lib/selenium-reporter.rb, line 62
def load_rspec_config
  require 'nokogiri' # this is a dependent lib for allure-rspec
  require 'allure-rspec'
  AllureRSpec.configure do |c|
    c.output_dir = xml_dir
  end
end
make_absolute(relative_path) click to toggle source
# File lib/selenium-reporter.rb, line 41
def make_absolute(relative_path)
  @output_dir = File.join(pwd, ENV['SE_OUTPUT_DIR'])
  ENV['SE_OUTPUT_DIR'] = output_dir
end
pwd() click to toggle source
# File lib/selenium-reporter.rb, line 37
def pwd
  Dir.pwd
end
report_dir() click to toggle source
# File lib/selenium-reporter.rb, line 54
def report_dir
  output_dir + '/report'
end
screenshot_dir() click to toggle source
# File lib/selenium-reporter.rb, line 46
def screenshot_dir
  output_dir + '/screenshot'
end
xml_dir() click to toggle source
# File lib/selenium-reporter.rb, line 50
def xml_dir
  output_dir + '/xml'
end