Class: Teaspoon::Drivers::SeleniumDriver
- Defined in:
- lib/teaspoon/drivers/selenium_driver.rb
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ SeleniumDriver
constructor
A new instance of SeleniumDriver.
- #run_specs(runner, url) ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ SeleniumDriver
Returns a new instance of SeleniumDriver.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/teaspoon/drivers/selenium_driver.rb', line 12 def initialize( = nil) ||= {} case when Hash then = when String then = JSON.parse() else raise Teaspoon::UnknownDriverOptions, "Unknown driver options -- supply a hash or json string" end rescue JSON::ParserError raise Teaspoon::UnknownDriverOptions, "Malformed driver options -- supply a hash or json string" end |
Instance Method Details
#run_specs(runner, url) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/teaspoon/drivers/selenium_driver.rb', line 24 def run_specs(runner, url) driver = Selenium::WebDriver.for([:client_driver]) driver.navigate.to(url) Selenium::WebDriver::Wait.new().until do done = driver.execute_script("return window.Teaspoon && window.Teaspoon.finished") driver.execute_script("return window.Teaspoon && window.Teaspoon.getMessages() || []").each do |line| runner.process("#{line}\n") end done end ensure driver.quit if driver end |