Skip to content

Commit

Permalink
Update testing and travis matrix for selenium-webdriver 3.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Oct 18, 2016
1 parent 4a1f558 commit b90a93a
Show file tree
Hide file tree
Showing 16 changed files with 153 additions and 60 deletions.
67 changes: 38 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,23 @@ rvm:
- rbx-3.26
gemfile:
- Gemfile
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
- JAVA_OPTS=-Djava.security.egd=file:/dev/urandom

addons:
firefox: 47.0.1
apt:
packages:
- awesome

matrix:
include:
- gemfile: Gemfile
rvm: 2.3.1
env: WINDOW_TEST=true
env:
- WINDOW_TEST=true
- gemfile: gemfiles/Gemfile.rspec-34
rvm: 2.3.1
env: CAPYBARA_CHROME=true
Expand All @@ -27,41 +39,40 @@ matrix:
rvm: 1.9.3
- gemfile: gemfiles/Gemfile.base-versions
rvm: 1.9.3
- gemfile: gemfiles/Gemfile.beta-versions
rvm: 2.4.0-preview2
- gemfile: gemfiles/Gemfile.beta-marionette
env: GECKODRIVER=true
- gemfile: Gemfile
rvm: 2.3.1
env:
- WINDOW_TEST=true
- CAPYBARA_MARIONETTE=true
addons:
firefox: latest-beta
firefox: latest
apt:
packages:
- awesome
- gemfile: gemfiles/Gemfile.beta-marionette
env: CAPYBARA_CHROME=true
- gemfile: gemfiles/Gemfile.beta-versions
rvm: 2.4.0-preview2
addons:
firefox: latest-beta
- gemfile: gemfiles/Gemfile.edge-marionette
rvm: 2.3.1
env:
- WINDOW_TEST=true
- CAPYBARA_MARIONETTE=true
addons:
firefox: latest-beta
apt:
sources:
- google-chrome
packages:
- google-chrome-stable
- awesome
allow_failures:
- gemfile: Gemfile
rvm: 2.3.1
env:
- WINDOW_TEST=true
- CAPYBARA_MARIONETTE=true
- gemfile: gemfiles/Gemfile.beta-versions
- gemfile: gemfiles/Gemfile.beta-marionette
- rvm: jruby-9.1.5.0
- gemfile: gemfiles/Gemfile.edge-marionette
- rvm: rbx-3.26
env:
global:
- NOKOGIRI_USE_SYSTEM_LIBRARIES=true
- JAVA_OPTS=-Djava.security.egd=file:/dev/urandom

addons:
firefox: 47.0.1
apt:
packages:
- awesome
- rvm: jruby-9.1.5.0

before_install:
- mkdir -p ~/drivers; export PATH=~/drivers:$PATH;
Expand All @@ -71,12 +82,10 @@ before_install:
FILE=`mktemp`; wget "$CHROMEDRIVER_URL" -qO $FILE && unzip $FILE chromedriver -d ~/drivers; rm $FILE; chmod 777 ~/drivers/chromedriver;
~/drivers/chromedriver --version;
fi
- if [ $GECKODRIVER ]; then
GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz";
FILE=`mktemp`; wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C ~/drivers -f $FILE geckodriver; rm $FILE; chmod 777 ~/drivers/geckodriver;
~/drivers/geckodriver --version;
fi
- if [[ $BUNDLE_GEMFILE =~ Gemfile.beta-marionette$ ]]; then
- GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz";
FILE=`mktemp`; wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C ~/drivers -f $FILE geckodriver; rm $FILE; chmod 777 ~/drivers/geckodriver;
~/drivers/geckodriver --version;
- if [[ $BUNDLE_GEMFILE =~ Gemfile.edge-marionette$ ]]; then
pushd ..;
git clone --depth 1 https://github.com/SeleniumHQ/selenium.git;
cd selenium; ./go //rb:gem:build;
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,21 @@ through an external gem.
**Need help?** Ask on the mailing list (please do not open an issue on
GitHub): http://groups.google.com/group/ruby-capybara

**Note: Firefox 48+** If you're using Firefox with selenium-webdriver, stay on either Firefox [45.0esr](https://ftp.mozilla.org/pub/firefox/releases/45.0esr/) or [47.0.1](https://ftp.mozilla.org/pub/firefox/releases/47.0.1/) and selenium-webdriver 2.53.4. Firefox 48+ requires geckodriver and selenium-webdriver v3, the combo of which currently has multiple issues and is feature incomplete.
**Note: Firefox 48+** If you're using Firefox with selenium-webdriver and want full functionality stay on either Firefox [45.0esr](https://ftp.mozilla.org/pub/firefox/releases/45.0esr/) or [47.0.1](https://ftp.mozilla.org/pub/firefox/releases/47.0.1/).
If using selenium-webdriver 3.0+ this will require configuring your driver with the `marionette: false` option as shown below

```ruby
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(
app,
browser: :firefox,
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false)
)
end
```

Using Firefox 48+ requires geckodriver and selenium-webdriver v3, the combo of which currently has multiple issues and is feature incomplete.
You can read more about the missing features [here](https://github.com/jnicklas/capybara/issues/1710).

## Table of contents

Expand Down
12 changes: 9 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,21 @@ require 'rspec/core/rake_task'
require 'cucumber/rake/task'
require 'yard'

desc "Run all examples"
desc "Run all examples with Firefox non-marionette"
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = %w[--color]
t.rspec_opts << '--format documentation' if RUBY_PLATFORM=='java'
# When we drop RSpec 2.x support we can rename spec_chrome.rb and implement this properly
# t.exclude_pattern = './spec/*{_chrome_spec.rb}'
t.pattern = './spec{,/*/**}/*{_spec.rb,_spec_firefox.rb}'
end

RSpec::Core::RakeTask.new(:all) do |t|
RSpec::Core::RakeTask.new(:spec_marionette) 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.rb,_spec_chrome.rb}'
t.pattern = './spec{,/*/**}/*{_spec.rb,_spec_marionette.rb}'
# t.pattern = './spec/*{_spec_legacy_firefox.rb}'
end

RSpec::Core::RakeTask.new(:spec_chrome) do |t|
Expand All @@ -36,6 +39,9 @@ end
task :travis do |t|
if ENV['CAPYBARA_CHROME']
Rake::Task[:spec_chrome].invoke
elsif ENV['CAPYBARA_MARIONETTE']
Rake::Task[:spec_marionette].invoke
Rake::Task[:cucumber].invoke
else
Rake::Task[:spec].invoke
Rake::Task[:cucumber].invoke
Expand Down
2 changes: 1 addition & 1 deletion capybara.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency("xpath", ["~> 2.0"])
s.add_runtime_dependency("addressable")

s.add_development_dependency("selenium-webdriver", ["~> 2.0"])
s.add_development_dependency("selenium-webdriver", [">= 2.0", "< 4.0"])
s.add_development_dependency("sinatra", [">= 0.9.4"])
s.add_development_dependency("rspec", [">= 2.2.0"])
s.add_development_dependency("launchy", [">= 2.0.4"])
Expand Down
3 changes: 2 additions & 1 deletion gemfiles/Gemfile.base-versions
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ gem 'tins', '= 1.6.0' # 1.7.0 requires ruby 2.0
gem 'mime-types', '<3.0' # 3.0 require ruby 2.0
gem 'addressable', '< 2.4.0' # 2.4.0 allows require 'addressable' previous don't
gem 'json', '< 2.0'

# We cannot test against older versions of selenium-webdriver without
# installing older compatible Firefox versions.

gem 'selenium-webdriver', '< 3.0.0'
gem 'term-ansicolor', '< 1.4.0'
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ gemspec :path => '..'
gem 'xpath', github: 'jnicklas/xpath'

gem 'selenium-webdriver', :path => '../../selenium/build/rb'
# git 'https://github.com/SeleniumHQ/selenium.git' do
# gem 'selenium-webdriver'
# end
# gem 'selenium-webdriver'
2 changes: 2 additions & 0 deletions gemfiles/Gemfile.ruby-19
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ gem 'xpath', :git => 'git://github.com/jnicklas/xpath.git'

gem 'term-ansicolor', '< 1.4.0'
gem 'tins', '< 1.7.0' # 1.7.0 requires ruby 2.0

gem 'selenium-webdriver', '< 3.0.0' # 3.0 requires ruby 2.0
2 changes: 1 addition & 1 deletion lib/capybara/spec/session/click_link_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
end
end

it "should return element clicked", twtw: true do
it "should return element clicked" do
el = @session.find(:link, 'Normal Anchor')
expect(@session.click_link('Normal Anchor')).to eq el
end
Expand Down
5 changes: 4 additions & 1 deletion spec/capybara_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@
end

it "should add a new server" do
skip "JRuby fails this because of path issues to geckodriver I think. Its tested in other runs - not worth figuring out at this time" if RUBY_PLATFORM == 'java'

require 'rack/handler/webrick'
Capybara.register_server :blob do |app, port, host|
Rack::Handler::WEBrick.run(app, Host: host, Port: port, AccessLog: [], Logger: WEBrick::Log::new(nil, 0))
end
Capybara.server = :blob
session = Capybara::Session.new(:selenium, TestApp.dup)
session = Capybara::Session.new(:selenium, TestApp.new)
session.visit('/')
expect(session.body).to include("Hello world!")
end
Expand Down
5 changes: 4 additions & 1 deletion spec/fixtures/selenium_driver_rspec_failure.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# frozen_string_literal: true
require 'spec_helper'
require 'selenium-webdriver'

RSpec.describe Capybara::Selenium::Driver do
it "should exit with a non-zero exit status" do
browser = Capybara::Selenium::Driver.new(TestApp, browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym).browser
options = { browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym }
options[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false) if ENV['LEGACY_FIREFOX']
browser = Capybara::Selenium::Driver.new(TestApp, options).browser
expect(true).to eq(false)
end
end
5 changes: 4 additions & 1 deletion spec/fixtures/selenium_driver_rspec_success.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# frozen_string_literal: true
require 'spec_helper'
require 'selenium-webdriver'

RSpec.describe Capybara::Selenium::Driver do
it "should exit with a zero exit status" do
browser = Capybara::Selenium::Driver.new(TestApp, browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym).browser
options = { browser: (ENV['SELENIUM_BROWSER'] || :firefox).to_sym }
options[:desired_capabilities] = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false) if ENV['LEGACY_FIREFOX']
browser = Capybara::Selenium::Driver.new(TestApp, options ).browser
expect(true).to eq(true)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
require 'capybara/dsl'
require 'capybara/rspec/matchers'

RSpec.describe Capybara::RSpecMatchers do
RSpec.shared_examples Capybara::RSpecMatchers do |session, mode|

include Capybara::DSL
include Capybara::RSpecMatchers

Expand Down Expand Up @@ -541,7 +542,7 @@

context 'with wait' do
before(:each) do
@session = TestSessions::Selenium
@session = session
@session.visit('/with_js')
end

Expand Down Expand Up @@ -586,7 +587,7 @@

context 'with wait' do
before(:each) do
@session = TestSessions::Selenium
@session = session
@session.visit('/with_js')
end

Expand Down
3 changes: 3 additions & 0 deletions spec/selenium_spec_chrome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ module TestSessions
Chrome = Capybara::Session.new(:selenium_chrome, TestApp)
end

skipped_tests = []
skipped_tests << :windows if ENV['TRAVIS'] && !ENV['WINDOW_TEST']

Capybara::SpecHelper.run_specs TestSessions::Chrome, "selenium_chrome", capybara_skip: [
:response_headers,
:status_code,
Expand Down
23 changes: 13 additions & 10 deletions spec/selenium_firefox_spec.rb → spec/selenium_spec_firefox.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
require 'spec_helper'
require "selenium-webdriver"
require 'shared_selenium_session'

Capybara.register_driver :selenium_focus do |app|
# profile = Selenium::WebDriver::Firefox::Profile.new
# profile["focusmanager.testmode"] = true
# Capybara::Selenium::Driver.new(app, browser: :firefox, profile: profile)
Capybara::Selenium::Driver.new(app, browser: :firefox)
require 'rspec/shared_spec_matchers'

Capybara.register_driver :selenium_firefox do |app|
Capybara::Selenium::Driver.new(
app,
browser: :firefox,
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false)
)
end

module TestSessions
Selenium = Capybara::Session.new(:selenium_focus, TestApp)
Selenium = Capybara::Session.new(:selenium_firefox, TestApp)
end

skipped_tests = [
Expand All @@ -23,13 +25,14 @@ module TestSessions

Capybara::SpecHelper.run_specs TestSessions::Selenium, "selenium", capybara_skip: skipped_tests

RSpec.describe "Capybara::Session with firefox" do
include_examples "Capybara::Session", TestSessions::Selenium, :selenium_focus
RSpec.describe "Capybara::Session with legacy firefox" do
include_examples "Capybara::Session", TestSessions::Selenium, :selenium_firefox
include_examples Capybara::RSpecMatchers, TestSessions::Selenium, :selenium_firefox
end

RSpec.describe Capybara::Selenium::Driver do
before do
@driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox)
@driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox, desired_capabilities: Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false))
end

describe '#quit' do
Expand Down
47 changes: 47 additions & 0 deletions spec/selenium_spec_marionette.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true
require 'spec_helper'
require "selenium-webdriver"
require 'shared_selenium_session'
require 'rspec/shared_spec_matchers'

Capybara.register_driver :selenium_marionette do |app|
Capybara::Selenium::Driver.new(
app,
browser: :firefox,
desired_capabilities: Selenium::WebDriver::Remote::Capabilities.firefox(marionette: true)
)
end

module TestSessions
SeleniumMarionette = Capybara::Session.new(:selenium_marionette, TestApp)
end

skipped_tests = [
:response_headers,
:status_code,
:trigger
]
skipped_tests << :windows if ENV['TRAVIS'] && !ENV['WINDOW_TEST']

Capybara::SpecHelper.run_specs TestSessions::SeleniumMarionette, "selenium", capybara_skip: skipped_tests

RSpec.describe "Capybara::Session with firefox" do
include_examples "Capybara::Session", TestSessions::SeleniumMarionette, :selenium_marionette
include_examples Capybara::RSpecMatchers, TestSessions::SeleniumMarionette, :selenium_marionette
end

RSpec.describe Capybara::Selenium::Driver do
before do
@driver = Capybara::Selenium::Driver.new(TestApp, browser: :firefox)
end

describe '#quit' do
it "should reset browser when quit" do
expect(@driver.browser).to be
@driver.quit
#access instance variable directly so we don't create a new browser instance
expect(@driver.instance_variable_get(:@browser)).to be_nil
end
end
end

Loading

0 comments on commit b90a93a

Please sign in to comment.