Update testing and travis matrix for selenium-webdriver 3.0 release

This commit is contained in:
Thomas Walpole 2016-10-13 19:50:03 -07:00
parent 4a1f558851
commit b90a93affe
16 changed files with 154 additions and 61 deletions

View File

@ -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
@ -27,41 +39,40 @@ matrix:
rvm: 1.9.3
- gemfile: gemfiles/Gemfile.base-versions
rvm: 1.9.3
- gemfile: Gemfile
rvm: 2.3.1
env:
- WINDOW_TEST=true
- CAPYBARA_MARIONETTE=true
addons:
firefox: latest
apt:
packages:
- awesome
- gemfile: gemfiles/Gemfile.beta-versions
rvm: 2.4.0-preview2
- gemfile: gemfiles/Gemfile.beta-marionette
env: GECKODRIVER=true
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:
packages:
- awesome
- gemfile: gemfiles/Gemfile.beta-marionette
env: CAPYBARA_CHROME=true
rvm: 2.3.1
addons:
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;
@ -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;

View File

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

View File

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

View File

@ -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"])

View File

@ -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'

View File

@ -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'

View File

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

View File

@ -187,7 +187,7 @@ Capybara::SpecHelper.spec '#click_link' do
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

View File

@ -46,11 +46,14 @@ RSpec.describe Capybara do
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

View File

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

View File

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

View File

@ -3,7 +3,8 @@ require 'spec_helper'
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
@ -541,7 +542,7 @@ RSpec.describe Capybara::RSpecMatchers do
context 'with wait' do
before(:each) do
@session = TestSessions::Selenium
@session = session
@session.visit('/with_js')
end
@ -586,7 +587,7 @@ RSpec.describe Capybara::RSpecMatchers do
context 'with wait' do
before(:each) do
@session = TestSessions::Selenium
@session = session
@session.visit('/with_js')
end

View File

@ -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,

View File

@ -2,16 +2,18 @@
require 'spec_helper'
require "selenium-webdriver"
require 'shared_selenium_session'
require 'rspec/shared_spec_matchers'
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)
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 = [
@ -23,13 +25,14 @@ skipped_tests << :windows if ENV['TRAVIS'] && !ENV['WINDOW_TEST']
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

View File

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

View File

@ -41,14 +41,16 @@ RSpec.shared_examples "Capybara::Session" do |session, mode|
end
it "should have return code 1 when running selenium_driver_rspec_failure.rb" do
ENV['SELENIUM_BROWSER'] = @session.driver.options[:browser].to_s
`rspec spec/fixtures/selenium_driver_rspec_failure.rb`
env = { 'SELENIUM_BROWSER' => @session.driver.options[:browser].to_s,
'LEGACY_FIREFOX' => (mode == :selenium_firefox ? 'TRUE' : nil) }
system(env, 'rspec spec/fixtures/selenium_driver_rspec_failure.rb')
expect($?.exitstatus).to eq(1)
end
it "should have return code 0 when running selenium_driver_rspec_success.rb" do
ENV['SELENIUM_BROWSER'] = @session.driver.options[:browser].to_s
`rspec spec/fixtures/selenium_driver_rspec_success.rb`
env = { 'SELENIUM_BROWSER' => @session.driver.options[:browser].to_s,
'LEGACY_FIREFOX' => (mode == :selenium_firefox ? 'TRUE' : nil) }
system(env, 'rspec spec/fixtures/selenium_driver_rspec_success.rb')
expect($?.exitstatus).to eq(0)
end
end