Skip to content

Commit

Permalink
Merge pull request #979 from twalpole/chrome
Browse files Browse the repository at this point in the history
Add selenium with chrome to the test suite
  • Loading branch information
jnicklas committed Nov 18, 2013
2 parents 660a281 + addecfa commit 1b73f77
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ matrix:
rvm: rbx-2.0.0
- gemfile: gemfiles/Gemfile.base-versions
rvm: jruby-19mode
before_install:
- 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
- sudo chmod 1777 /dev/shm
before_script:
- sh -e /etc/init.d/xvfb start
- export DISPLAY=:99.0
script: "bundle exec rake travis"

8 changes: 7 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -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]
2 changes: 1 addition & 1 deletion lib/capybara/spec/session/attach_file_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/capybara/spec/session/fill_in_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
extract_results(@session)['description'].should == 'is <strong>very</strong> 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"
Expand Down
21 changes: 21 additions & 0 deletions spec/selenium_spec_chrome.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'

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 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
]

0 comments on commit 1b73f77

Please sign in to comment.