File: test_runner.rb

package info (click to toggle)
qunit-selenium 0.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 152 kB
  • sloc: ruby: 188; makefile: 3
file content (26 lines) | stat: -rw-r--r-- 635 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
require 'selenium-webdriver'
require_relative 'test_run'

module QUnit
  module Selenium
    class TestRunner
      def initialize(driver = nil)
        @driver = driver || ::Selenium::WebDriver.for(:chrome)
      end

      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
    end
  end
end