Class: Teaspoon::Driver::Selenium
- Defined in:
- lib/teaspoon/driver/selenium.rb
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ Selenium
constructor
A new instance of Selenium.
- #run_specs(runner, url) ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ Selenium
Returns a new instance of Selenium.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/teaspoon/driver/selenium.rb', line 14 def initialize( = nil) ||= {} case when Hash then @options = when String then @options = JSON.parse() else raise Teaspoon::DriverOptionsError.new(types: "hash or json string") end rescue JSON::ParserError raise Teaspoon::DriverOptionsError.new(types: "hash or json string") end |
Instance Method Details
#run_specs(runner, url) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/teaspoon/driver/selenium.rb', line 25 def run_specs(runner, url) driver = ::Selenium::WebDriver.for( [:client_driver], **[:selenium_options].to_hash. ) 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 |