From d1ec92ff16f5c63cb87d8bb3362926ba2f023101 Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Mon, 25 Feb 2013 11:13:03 -0800 Subject: [PATCH 1/3] Add selenium with chrome to the travis test suite --- .travis.yml | 5 +++++ Rakefile | 8 +++++++- lib/capybara/spec/session/attach_file_spec.rb | 2 +- spec/selenium_spec_chrome.rb | 20 +++++++++++++++++++ 4 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 spec/selenium_spec_chrome.rb diff --git a/.travis.yml b/.travis.yml index 4acc84d93..24a9d8ceb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,11 @@ matrix: rvm: rbx-2.0.0 - gemfile: gemfiles/Gemfile.base-versions rvm: jruby-19mode +before_install: + - URL='https://chromedriver.googlecode.com/files/chromedriver_linux32_26.0.1383.0.zip'; FILE=`mktemp`; wget "$URL" -qO $FILE && sudo unzip $FILE chromedriver -d /usr/local/bin; rm $FILE + - URL='https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb'; FILE=`mktemp`; wget "$URL" -qO $FILE && sudo dpkg -i $FILE; rm $FILE before_script: - sh -e /etc/init.d/xvfb start - export DISPLAY=:99.0 +script: "bundle exec rake travis" + diff --git a/Rakefile b/Rakefile index 1fecf80f9..52b51cdc8 100644 --- a/Rakefile +++ b/Rakefile @@ -5,9 +5,13 @@ require 'yard' desc "Run all examples" RSpec::Core::RakeTask.new(:spec) do |t| - #t.rspec_path = 'bin/rspec' t.rspec_opts = %w[--color] end + +RSpec::Core::RakeTask.new(:spec_with_chrome) do |t| + t.rspec_opts = %w[--color] + t.pattern = './spec{,/*/**}/*{_spec.rb,_spec_chrome.rb}' +end YARD::Rake::YardocTask.new do |t| t.files = ['lib/**/*.rb'] @@ -18,4 +22,6 @@ Cucumber::Rake::Task.new(:cucumber) do |task| task.cucumber_opts = ['--format=progress', 'features'] end +task :travis => [:spec_with_chrome, :cucumber] + task :default => [:spec, :cucumber] diff --git a/lib/capybara/spec/session/attach_file_spec.rb b/lib/capybara/spec/session/attach_file_spec.rb index c8bc486be..ab8bb3484 100644 --- a/lib/capybara/spec/session/attach_file_spec.rb +++ b/lib/capybara/spec/session/attach_file_spec.rb @@ -64,7 +64,7 @@ end it "should not break when using HTML5 multiple file input uploading multiple files" do - pending "Selenium is buggy on this, see http://code.google.com/p/selenium/issues/detail?id=2239" if @session.respond_to?(:mode) && [:selenium, :selenium_focus].include?(@session.mode) + pending "Selenium is buggy on this, see http://code.google.com/p/selenium/issues/detail?id=2239" if @session.respond_to?(:mode) && @session.mode.to_s =~ /^selenium/ @session.attach_file "Multiple Documents", [@test_file_path, @another_test_file_path] @session.click_button('Upload Multiple') @session.body.should include("2 | ")#number of files diff --git a/spec/selenium_spec_chrome.rb b/spec/selenium_spec_chrome.rb new file mode 100644 index 000000000..e1ece5941 --- /dev/null +++ b/spec/selenium_spec_chrome.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +Capybara.register_driver :selenium_chrome do |app| + Capybara::Selenium::Driver.new(app, :browser => :chrome) +end + +class ChromeTestApp < TestApp + # Object.id is different from the TestApp used in firefox session so + # a new Capybar::Server instance will get launched for chrome testing +end + +module TestSessions + Chrome = Capybara::Session.new(:selenium_chrome, ChromeTestApp) +end + +Capybara::SpecHelper.run_specs TestSessions::Chrome, "selenium_chrome", :skip => [ + :response_headers, + :status_code, + :trigger +] From f4af487a3f03032666468d1814f1a76c23d9bfce Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Fri, 15 Nov 2013 13:52:07 -0800 Subject: [PATCH 2/3] update to latest chromedriver with permissions fix, and install latest chrome --- .travis.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 24a9d8ceb..e62013a5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,8 +21,11 @@ matrix: - gemfile: gemfiles/Gemfile.base-versions rvm: jruby-19mode before_install: - - URL='https://chromedriver.googlecode.com/files/chromedriver_linux32_26.0.1383.0.zip'; FILE=`mktemp`; wget "$URL" -qO $FILE && sudo unzip $FILE chromedriver -d /usr/local/bin; rm $FILE - - URL='https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb'; FILE=`mktemp`; wget "$URL" -qO $FILE && sudo dpkg -i $FILE; rm $FILE + - URL='http://chromedriver.storage.googleapis.com/2.6/chromedriver_linux64.zip'; FILE=`mktemp`; wget "$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 before_script: - sh -e /etc/init.d/xvfb start - export DISPLAY=:99.0 From addecfadd081bda9384fcf92ddf25327378ffe4a Mon Sep 17 00:00:00 2001 From: Thomas Walpole Date: Mon, 18 Nov 2013 12:47:05 -0800 Subject: [PATCH 3/3] use no-sandbox option for chrome and adjust permissions for /dev/shm for travis build --- .travis.yml | 1 + lib/capybara/spec/session/fill_in_spec.rb | 2 +- spec/selenium_spec_chrome.rb | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e62013a5d..f46c80d35 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,6 +26,7 @@ before_install: - 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 + - sudo chmod 1777 /dev/shm before_script: - sh -e /etc/init.d/xvfb start - export DISPLAY=:99.0 diff --git a/lib/capybara/spec/session/fill_in_spec.rb b/lib/capybara/spec/session/fill_in_spec.rb index 3bc051a36..5b2daabf1 100644 --- a/lib/capybara/spec/session/fill_in_spec.rb +++ b/lib/capybara/spec/session/fill_in_spec.rb @@ -57,7 +57,7 @@ extract_results(@session)['description'].should == 'is very secret!' end - it "should handle newlines in a textarea", tw: true do + it "should handle newlines in a textarea" do @session.fill_in('form_description', :with => "\nSome text\n") @session.click_button('awesome') extract_results(@session)['description'].should == "\r\nSome text\r\n" diff --git a/spec/selenium_spec_chrome.rb b/spec/selenium_spec_chrome.rb index e1ece5941..37290087d 100644 --- a/spec/selenium_spec_chrome.rb +++ b/spec/selenium_spec_chrome.rb @@ -1,7 +1,8 @@ require 'spec_helper' Capybara.register_driver :selenium_chrome do |app| - Capybara::Selenium::Driver.new(app, :browser => :chrome) + args = ENV['TRAVIS'] ? ['no-sandbox' ] : [] + Capybara::Selenium::Driver.new(app, :browser => :chrome, :args => args) end class ChromeTestApp < TestApp