Skip to content

Commit

Permalink
run chrome test separately once
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed May 22, 2015
1 parent d4f416e commit 6b89b9b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 16 deletions.
19 changes: 12 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ matrix:
rvm: 2.2
- gemfile: gemfiles/Gemfile.beta-versions
rvm: jruby-9.0.0.0.pre1
- gemfile: Gemfile
rvm: 2.2
env: CAPYBARA_CHROME=true
allow_failures:
- gemfile: gemfiles/Gemfile.beta-versions
rvm: 2.2
Expand All @@ -26,13 +29,15 @@ env:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true

before_install:
- CHROMEDRIVER_VERSION=$(wget -q -O - http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
- CHROMEDRIVER_URL="http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip"
- FILE=`mktemp`; wget "$CHROMEDRIVER_URL" -qO $FILE && sudo unzip $FILE chromedriver -d /usr/local/bin; rm $FILE; sudo chmod 777 /usr/local/bin/chromedriver
- wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
- sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list'
- sudo apt-get update
- sudo apt-get install google-chrome-stable --force-yes
- if [ $CAPYBARA_CHROME ]; then
CHROMEDRIVER_VERSION=$(wget -q -O - http://chromedriver.storage.googleapis.com/LATEST_RELEASE);
CHROMEDRIVER_URL="http://chromedriver.storage.googleapis.com/$CHROMEDRIVER_VERSION/chromedriver_linux64.zip";
FILE=`mktemp`; wget "$CHROMEDRIVER_URL" -qO $FILE && sudo unzip $FILE chromedriver -d /usr/local/bin; rm $FILE; sudo chmod 777 /usr/local/bin/chromedriver;
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -;
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list';
sudo apt-get update;
sudo apt-get install google-chrome-stable --force-yes;
fi
- sudo chmod 1777 /dev/shm
- sudo apt-get install awesome -y
before_script:
Expand Down
16 changes: 15 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ RSpec::Core::RakeTask.new(:spec_with_chrome) do |t|
t.pattern = './spec{,/*/**}/*{_spec.rb,_spec_chrome.rb}'
end

RSpec::Core::RakeTask.new(:spec_chrome) do |t|
t.rspec_opts = %w[--color]
# jruby buffers the progress formatter so travis doesn't see output often enough
t.rspec_opts << '--format documentation' if RUBY_PLATFORM=='java'
t.pattern = './spec/*{_spec_chrome.rb}'
end

YARD::Rake::YardocTask.new do |t|
t.files = ['lib/**/*.rb']
t.options = %w(--markup=markdown)
Expand All @@ -24,6 +31,13 @@ Cucumber::Rake::Task.new(:cucumber) do |task|
task.cucumber_opts = ['--format=progress', 'features']
end

task :travis => [:spec_with_chrome, :cucumber]
task :travis do |t|
if ENV['CAPYBARA_CHROME']
Rake::Task[:spec_chrome].invoke
else
Rake::Task[:spec].invoke
Rake::Task[:cucumber].invoke
end
end

task :default => [:spec, :cucumber]
5 changes: 4 additions & 1 deletion lib/capybara/selenium/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ def quit
end

def invalid_element_errors
[Selenium::WebDriver::Error::StaleElementReferenceError, Selenium::WebDriver::Error::UnhandledError, Selenium::WebDriver::Error::ElementNotVisibleError]
[Selenium::WebDriver::Error::StaleElementReferenceError,
Selenium::WebDriver::Error::UnhandledError,
Selenium::WebDriver::Error::ElementNotVisibleError,
Selenium::WebDriver::Error::InvalidSelectorError] # Work around a race condition that can occur with chromedriver and #go_back/#go_forward
end

def no_such_window_error
Expand Down
10 changes: 3 additions & 7 deletions spec/selenium_spec_chrome.rb
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
require 'spec_helper'
require 'selenium-webdriver'

Capybara.register_driver :selenium_chrome do |app|
args = ENV['TRAVIS'] ? ['no-sandbox' ] : []
Capybara::Selenium::Driver.new(app, :browser => :chrome, :args => args)
end

class ChromeTestApp < TestApp
# Object.id is different from the TestApp used in firefox session so
# a new Capybara::Server instance will get launched for chrome testing
end

module TestSessions
Chrome = Capybara::Session.new(:selenium_chrome, ChromeTestApp)
Chrome = Capybara::Session.new(:selenium_chrome, TestApp)
end

Capybara::SpecHelper.run_specs TestSessions::Chrome, "selenium_chrome", :capybara_skip => [
:response_headers,
:status_code,
:trigger
:trigger
] unless ENV['TRAVIS'] && (RUBY_PLATFORM == 'java')

0 comments on commit 6b89b9b

Please sign in to comment.