1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Merge pull request #2132 from teamcapybara/firefox

Change from using `marionette` to `firefox`
This commit is contained in:
Thomas Walpole 2018-11-18 19:15:37 -08:00 committed by GitHub
commit 7cce5e8945
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 44 additions and 44 deletions

View file

@ -62,17 +62,17 @@ matrix:
apt:
packages:
- awesome
- gemfile: gemfiles/Gemfile.edge-marionette
- gemfile: gemfiles/Gemfile.edge-firefox
rvm: ruby-head
env:
- CAPYBARA_FF=true
- CAPYBARA_REMOTE=true
- gemfile: gemfiles/Gemfile.edge-marionette
- gemfile: gemfiles/Gemfile.edge-firefox
rvm: ruby-head
env:
- CAPYBARA_REMOTE=true
- HEADLESS=true
- gemfile: gemfiles/Gemfile.edge-marionette
- gemfile: gemfiles/Gemfile.edge-firefox
rvm: ruby-head
env: CAPYBARA_FF=true RUBY_OPT=--jit
addons:
@ -94,11 +94,11 @@ matrix:
script: bundle exec rake spec_rack
allow_failures:
- gemfile: gemfiles/Gemfile.beta-versions
- gemfile: gemfiles/Gemfile.edge-marionette
- gemfile: gemfiles/Gemfile.edge-firefox
- env: W3C=true HEADLESS=true
before_install:
- gem update --system
- if [[ $BUNDLE_GEMFILE =~ Gemfile.edge-marionette$ ]]; then
- if [[ $BUNDLE_GEMFILE =~ Gemfile.edge-firefox$ ]]; then
pushd ..;
git clone --depth 1 https://github.com/SeleniumHQ/selenium.git;
cd selenium; ./go //rb:gem:build;

View file

@ -5,13 +5,13 @@ require 'rspec/core/rake_task'
require 'cucumber/rake/task'
require 'yard'
desc 'Run all examples with Firefox non-marionette'
desc 'Run all examples with Firefox'
rspec_opts = %w[--color]
RSpec::Core::RakeTask.new(:spec_marionette) do |t|
RSpec::Core::RakeTask.new(:spec_firefox) do |t|
t.rspec_opts = rspec_opts
t.pattern = './spec{,/*/**}/*{_spec.rb,_spec_marionette.rb}'
t.pattern = './spec{,/*/**}/*{_spec.rb,_spec_firefox.rb}'
end
%w[chrome ie edge chrome_remote firefox_remote].each do |driver|
@ -26,7 +26,7 @@ RSpec::Core::RakeTask.new(:spec_rack) do |t|
t.pattern = './spec{,/*/**}/*{_spec.rb}'
end
task spec: [:spec_marionette]
task spec: [:spec_firefox]
YARD::Rake::YardocTask.new do |t|
t.files = ['lib/**/*.rb']
@ -41,7 +41,7 @@ task :travis do
if ENV['CAPYBARA_REMOTE'] && ENV['CAPYBARA_FF']
Rake::Task[:spec_firefox_remote].invoke
elsif ENV['CAPYBARA_FF']
Rake::Task[:spec_marionette].invoke
Rake::Task[:spec_firefox].invoke
elsif ENV['CAPYBARA_IE']
Rake::Task[:spec_ie].invoke
elsif ENV['CAPYBARA_EDGE']

View file

@ -79,7 +79,7 @@ module Capybara
if count
message << " #{occurrences count}"
elsif between
message << " between #{between.first} and #{between.end ? between.last : "infinite"} times"
message << " between #{between.first} and #{between.end ? between.last : 'infinite'} times"
elsif maximum
message << " at most #{occurrences maximum}"
elsif minimum

View file

@ -353,7 +353,7 @@ private
extend ChromeDriver
when :firefox
require 'capybara/selenium/patches/pause_duration_fix' if pause_broken?(sel_driver)
extend MarionetteDriver if sel_driver.capabilities.is_a?(::Selenium::WebDriver::Remote::W3C::Capabilities)
extend FirefoxDriver if sel_driver.capabilities.is_a?(::Selenium::WebDriver::Remote::W3C::Capabilities)
end
end
@ -396,4 +396,4 @@ private
end
require 'capybara/selenium/driver_specializations/chrome_driver'
require 'capybara/selenium/driver_specializations/marionette_driver'
require 'capybara/selenium/driver_specializations/firefox_driver'

View file

@ -1,8 +1,8 @@
# frozen_string_literal: true
require 'capybara/selenium/nodes/marionette_node'
require 'capybara/selenium/nodes/firefox_node'
module Capybara::Selenium::Driver::MarionetteDriver
module Capybara::Selenium::Driver::FirefoxDriver
def resize_window_to(handle, width, height)
within_given_window(handle) do
# Don't set the size if already set - See https://github.com/mozilla/geckodriver/issues/643
@ -45,6 +45,6 @@ module Capybara::Selenium::Driver::MarionetteDriver
private
def build_node(native_node)
::Capybara::Selenium::MarionetteNode.new(self, native_node)
::Capybara::Selenium::FirefoxNode.new(self, native_node)
end
end

View file

@ -2,7 +2,7 @@
require 'capybara/selenium/extensions/html5_drag'
class Capybara::Selenium::MarionetteNode < Capybara::Selenium::Node
class Capybara::Selenium::FirefoxNode < Capybara::Selenium::Node
include Html5Drag
def click(keys = [], **options)

View file

@ -15,7 +15,7 @@ browser_options.profile = Selenium::WebDriver::Firefox::Profile.new.tap do |prof
profile['browser.helperApps.neverAsk.saveToDisk'] = 'text/csv'
end
Capybara.register_driver :selenium_marionette do |app|
Capybara.register_driver :selenium_firefox do |app|
# ::Selenium::WebDriver.logger.level = "debug"
Capybara::Selenium::Driver.new(
app,
@ -26,7 +26,7 @@ Capybara.register_driver :selenium_marionette do |app|
)
end
Capybara.register_driver :selenium_marionette_clear_storage do |app|
Capybara.register_driver :selenium_firefox_clear_storage do |app|
Capybara::Selenium::Driver.new(
app,
browser: :firefox,
@ -37,7 +37,7 @@ Capybara.register_driver :selenium_marionette_clear_storage do |app|
end
module TestSessions
SeleniumMarionette = Capybara::Session.new(:selenium_marionette, TestApp)
SeleniumFirefox = Capybara::Session.new(:selenium_firefox, TestApp)
end
skipped_tests = %i[response_headers status_code trigger]
@ -45,21 +45,21 @@ skipped_tests << :windows if ENV['TRAVIS'] && ENV['SKIP_WINDOW']
$stdout.puts `#{Selenium::WebDriver::Firefox.driver_path} --version` if ENV['CI']
Capybara::SpecHelper.run_specs TestSessions::SeleniumMarionette, 'selenium', capybara_skip: skipped_tests do |example|
Capybara::SpecHelper.run_specs TestSessions::SeleniumFirefox, 'selenium', capybara_skip: skipped_tests do |example|
case example.metadata[:full_description]
when 'Capybara::Session selenium node #click should allow multiple modifiers'
pending "Firefox doesn't generate an event for shift+control+click" if marionette_gte?(62, @session) && !Gem.win_platform?
pending "Firefox doesn't generate an event for shift+control+click" if firefox_gte?(62, @session) && !Gem.win_platform?
when /^Capybara::Session selenium node #double_click/
pending "selenium-webdriver/geckodriver doesn't generate double click event" if marionette_lt?(59, @session)
pending "selenium-webdriver/geckodriver doesn't generate double click event" if firefox_lt?(59, @session)
when 'Capybara::Session selenium #accept_prompt should accept the prompt with a blank response when there is a default'
pending "Geckodriver doesn't set a blank response in FF < 63 - https://bugzilla.mozilla.org/show_bug.cgi?id=1486485" if marionette_lt?(63, @session)
pending "Geckodriver doesn't set a blank response in FF < 63 - https://bugzilla.mozilla.org/show_bug.cgi?id=1486485" if firefox_lt?(63, @session)
when 'Capybara::Session selenium #attach_file with multipart form should fire change once for each set of files uploaded'
pending 'Gekcodriver appends files so we have to first call clear for multiple files which creates an extra change ' \
'if files are already set'
when 'Capybara::Session selenium #attach_file with multipart form should fire change once when uploading multiple files from empty'
pending "FF < 62 doesn't support setting all files at once" if marionette_lt?(62, @session)
pending "FF < 62 doesn't support setting all files at once" if firefox_lt?(62, @session)
when 'Capybara::Session selenium #accept_confirm should work with nested modals'
skip 'Broken in FF 63 - https://bugzilla.mozilla.org/show_bug.cgi?id=1487358' if marionette_gte?(63, @session)
skip 'Broken in FF 63 - https://bugzilla.mozilla.org/show_bug.cgi?id=1487358' if firefox_gte?(63, @session)
when 'Capybara::Session selenium #click_link can download a file'
skip 'Need to figure out testing of file downloading on windows platform' if Gem.win_platform?
when 'Capybara::Session selenium #reset_session! removes ALL cookies'
@ -69,8 +69,8 @@ end
RSpec.describe 'Capybara::Session with firefox' do # rubocop:disable RSpec/MultipleDescribes
include Capybara::SpecHelper
include_examples 'Capybara::Session', TestSessions::SeleniumMarionette, :selenium_marionette
include_examples Capybara::RSpecMatchers, TestSessions::SeleniumMarionette, :selenium_marionette
include_examples 'Capybara::Session', TestSessions::SeleniumFirefox, :selenium_firefox
include_examples Capybara::RSpecMatchers, TestSessions::SeleniumFirefox, :selenium_firefox
end
RSpec.describe Capybara::Selenium::Driver do
@ -126,7 +126,7 @@ RSpec.describe Capybara::Selenium::Driver do
context 'storage' do
describe '#reset!' do
it 'does not clear either storage by default' do
@session = TestSessions::SeleniumMarionette
@session = TestSessions::SeleniumFirefox
@session.visit('/with_js')
@session.find(:css, '#set-storage').click
@session.reset!
@ -136,7 +136,7 @@ RSpec.describe Capybara::Selenium::Driver do
end
it 'clears storage when set' do
@session = Capybara::Session.new(:selenium_marionette_clear_storage, TestApp)
@session = Capybara::Session.new(:selenium_firefox_clear_storage, TestApp)
@session.visit('/with_js')
@session.find(:css, '#set-storage').click
@session.reset!
@ -151,7 +151,7 @@ end
RSpec.describe Capybara::Selenium::Node do
context '#click' do
it 'warns when attempting on a table row' do
session = TestSessions::SeleniumMarionette
session = TestSessions::SeleniumFirefox
session.visit('/tables')
tr = session.find(:css, '#agent_table tr:first-child')
allow(tr.base).to receive(:warn)
@ -160,7 +160,7 @@ RSpec.describe Capybara::Selenium::Node do
end
it 'should allow multiple modifiers', requires: [:js] do
session = TestSessions::SeleniumMarionette
session = TestSessions::SeleniumFirefox
session.visit('with_js')
# Firefox v62+ doesn't generate an event for control+shift+click
session.find(:css, '#click-test').click(:alt, :ctrl, :meta)
@ -171,7 +171,7 @@ RSpec.describe Capybara::Selenium::Node do
context '#send_keys' do
it 'should process space' do
session = TestSessions::SeleniumMarionette
session = TestSessions::SeleniumFirefox
session.visit('/form')
session.find(:css, '#address1_city').send_keys('ocean', [:shift, :space, 'side'])
expect(session.find(:css, '#address1_city').value).to eq 'ocean SIDE'

View file

@ -62,19 +62,19 @@ skipped_tests << :windows if ENV['TRAVIS'] && (ENV['SKIP_WINDOW'] || ENV['HEADLE
Capybara::SpecHelper.run_specs TestSessions::RemoteFirefox, FIREFOX_REMOTE_DRIVER.to_s, capybara_skip: skipped_tests do |example|
case example.metadata[:full_description]
when 'Capybara::Session selenium_firefox_remote node #click should allow multiple modifiers'
skip "Firefox doesn't generate an event for shift+control+click" if marionette_gte?(62, @session)
skip "Firefox doesn't generate an event for shift+control+click" if firefox_gte?(62, @session)
when 'Capybara::Session selenium_firefox_remote #accept_prompt should accept the prompt with a blank response when there is a default'
pending "Geckodriver doesn't set a blank response in FF < 63 - https://bugzilla.mozilla.org/show_bug.cgi?id=1486485" if marionette_lt?(63, @session)
pending "Geckodriver doesn't set a blank response in FF < 63 - https://bugzilla.mozilla.org/show_bug.cgi?id=1486485" if firefox_lt?(63, @session)
when 'Capybara::Session selenium_firefox_remote #attach_file with multipart form should fire change once for each set of files uploaded'
pending 'Gekcodriver appends files so we have to first call clear for multiple files which creates an extra change ' \
'if files are already set'
when 'Capybara::Session selenium_firefox_remote #attach_file with multipart form should fire change once when uploading multiple files from empty'
pending "FF < 62 doesn't support setting all files at once" if marionette_lt?(62, @session)
pending "FF < 62 doesn't support setting all files at once" if firefox_lt?(62, @session)
when 'Capybara::Session selenium_firefox_remote #reset_session! removes ALL cookies'
pending "Geckodriver doesn't provide a way to remove cookies outside the current domain"
when /#accept_confirm should work with nested modals$/
# skip because this is timing based and hence flaky when set to pending
skip 'Broken in FF 63 - https://bugzilla.mozilla.org/show_bug.cgi?id=1487358' if marionette_gte?(63, @session)
skip 'Broken in FF 63 - https://bugzilla.mozilla.org/show_bug.cgi?id=1487358' if firefox_gte?(63, @session)
end
end

View file

@ -295,7 +295,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
describe 'Element#drag_to' do
before do
skip "Firefox < 62 doesn't support a DataTransfer constuctor" if marionette_lt?(62.0, session)
skip "Firefox < 62 doesn't support a DataTransfer constuctor" if firefox_lt?(62.0, session)
skip "IE doesn't support a DataTransfer constuctor" if ie?(session)
end
@ -336,7 +336,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
describe 'Capybara#Node#attach_file' do
it 'can attach a directory' do
pending "Geckodriver doesn't support uploading a directory" if marionette?(session)
pending "Geckodriver doesn't support uploading a directory" if firefox?(session)
pending "Selenium remote doesn't support transferring a directory" if remote?(session)
pending "Headless Chrome doesn't support directory upload - https://bugs.chromium.org/p/chromedriver/issues/detail?id=2521&q=directory%20upload&colspec=ID%20Status%20Pri%20Owner%20Summary" if chrome?(session) && ENV['HEADLESS']

View file

@ -6,17 +6,17 @@ require 'webdrivers' if ENV['CI']
module Capybara
module SpecHelper
def marionette?(session)
def firefox?(session)
browser_name(session) == :firefox &&
session.driver.browser.capabilities.is_a?(::Selenium::WebDriver::Remote::W3C::Capabilities)
end
def marionette_lt?(version, session)
marionette?(session) && (session.driver.browser.capabilities[:browser_version].to_f < version)
def firefox_lt?(version, session)
firefox?(session) && (session.driver.browser.capabilities[:browser_version].to_f < version)
end
def marionette_gte?(version, session)
marionette?(session) && (session.driver.browser.capabilities[:browser_version].to_f >= version)
def firefox_gte?(version, session)
firefox?(session) && (session.driver.browser.capabilities[:browser_version].to_f >= version)
end
def chrome?(session)