Class: QUnit::Selenium::TestRunner

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

Instance Method Summary collapse

Constructor Details

#initialize(driver = nil) ⇒ TestRunner

Returns a new instance of TestRunner.



7
8
9
# File 'lib/qunit/selenium/test_runner.rb', line 7

def initialize(driver = nil)
  @driver = driver || ::Selenium::WebDriver.for(:firefox)
end

Instance Method Details

#open(url, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/qunit/selenium/test_runner.rb', line 11

def open(url, options = {})
  timeout = options[:timeout] || 10
  force_refresh = options[:force_refresh] || false
  
  @driver.get url
  @driver.navigate.refresh if force_refresh

  TestRun.new(@driver).tap do |run|
    ::Selenium::WebDriver::Wait.new(timeout: timeout).until do
      run.completed?
    end
  end.result
end