Class: QUnit::Selenium::Cli

Inherits:
Thor
  • Object
show all
Defined in:
lib/qunit/selenium/cli.rb

Instance Method Summary collapse

Instance Method Details

#open(url) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/qunit/selenium/cli.rb', line 12

def open(url)
  profile = ::Selenium::WebDriver::Firefox::Profile.new
  driver = ::Selenium::WebDriver.for :firefox, profile: profile

  begin
    test_result = TestRunner.new(driver).open(url, timeout: options[:timeout])
    driver.save_screenshot options[:screenshot] if options[:screenshot]

    print_report(test_result)

    error = test_result.assertions[:failed] > 0
  rescue => e
    puts "Error: #{e}"
    driver.save_screenshot('qunit-selenium-error.png')
    error = true
  ensure
    driver.quit
  end
  exit(1) if error
end