Skip to content

Commit

Permalink
Teaspoon: try selenium
Browse files Browse the repository at this point in the history
Teaspoon: use chrome driver, via monkey patch

Teaspoon master has support for driver_options, but no new gem release has been cut for 2+ years (?). The merged PR including this support is here:
jejacks0n/teaspoon#537

Monkey patching teaspoon locally to add chrome support until we change test frameworks.

Rubocop: clean up StringLiterals and SafeNavigation

Teaspoon: set driver explicitly to :chrome

Teaspoon: One more try to spin chrome here.
  • Loading branch information
ewlarson committed Jan 29, 2019
1 parent c65dab5 commit fa18d47
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion spec/teaspoon_env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@
require File.expand_path('../../config/environment', __FILE__)
end

# Teaspoon doesn't allow you to pass client driver options to the Selenium WebDriver. This monkey patch
# is a temporary fix until this PR is merged: https://github.com/jejacks0n/teaspoon/pull/519.
require 'teaspoon/driver/selenium'

Teaspoon::Driver::Selenium.class_eval do
def run_specs(runner, url)
driver = ::Selenium::WebDriver.for(
driver_options[:client_driver],
**driver_options[:selenium_options].to_hash.to_options
)
driver.navigate.to(url)

::Selenium::WebDriver::Wait.new(driver_options).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
end
end

Teaspoon.configure do |config|
# Determines where the Teaspoon routes will be mounted. Changing this to "/jasmine" would allow you to browse to
# `http://localhost:3000/jasmine` to run your tests.
Expand Down Expand Up @@ -99,7 +123,13 @@
# PhantomJS: https://github.com/modeset/teaspoon/wiki/Using-PhantomJS
# Selenium Webdriver: https://github.com/modeset/teaspoon/wiki/Using-Selenium-WebDriver
# Capybara Webkit: https://github.com/modeset/teaspoon/wiki/Using-Capybara-Webkit
# config.driver = :phantomjs
config.driver = :selenium
config.driver_options = {
client_driver: :chrome,
selenium_options: {
options: Selenium::WebDriver::Chrome::Options.new(args: ['headless', 'disable-gpu'])
}
}

# Specify additional options for the driver.
#
Expand Down

0 comments on commit fa18d47

Please sign in to comment.