mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Support selenium-webdriver 3.14 remote multiple upload and test remote drivers with master branch of selenium
This commit is contained in:
parent
8f07330783
commit
679548cea1
5 changed files with 21 additions and 5 deletions
11
.travis.yml
11
.travis.yml
|
@ -58,6 +58,16 @@ matrix:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- awesome
|
- awesome
|
||||||
|
- gemfile: gemfiles/Gemfile.edge-marionette
|
||||||
|
rvm: ruby-head
|
||||||
|
env:
|
||||||
|
- CAPYBARA_FF=true
|
||||||
|
- CAPYBARA_REMOTE=true
|
||||||
|
- gemfile: gemfiles/Gemfile.edge-marionette
|
||||||
|
rvm: ruby-head
|
||||||
|
env:
|
||||||
|
- CAPYBARA_REMOTE=true
|
||||||
|
- HEADLESS=true
|
||||||
- gemfile: gemfiles/Gemfile.edge-marionette
|
- gemfile: gemfiles/Gemfile.edge-marionette
|
||||||
rvm: ruby-head
|
rvm: ruby-head
|
||||||
env: CAPYBARA_FF=true
|
env: CAPYBARA_FF=true
|
||||||
|
@ -66,6 +76,7 @@ matrix:
|
||||||
apt:
|
apt:
|
||||||
packages:
|
packages:
|
||||||
- awesome
|
- awesome
|
||||||
|
|
||||||
- gemfile: Gemfile
|
- gemfile: Gemfile
|
||||||
rvm: 2.4.4
|
rvm: 2.4.4
|
||||||
env: CAPYBARA_FF=true HEADLESS=true
|
env: CAPYBARA_FF=true HEADLESS=true
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Capybara::Selenium::ChromeNode < Capybara::Selenium::Node
|
||||||
super(value)
|
super(value)
|
||||||
rescue ::Selenium::WebDriver::Error::ExpectedError => e
|
rescue ::Selenium::WebDriver::Error::ExpectedError => e
|
||||||
if e.message =~ /File not found : .+\n.+/m
|
if e.message =~ /File not found : .+\n.+/m
|
||||||
raise ArgumentError, "Selenium with remote Chrome doesn't currently support multiple file upload"
|
raise ArgumentError, "Selenium < 3.14 with remote Chrome doesn't support multiple file upload"
|
||||||
end
|
end
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,6 +29,7 @@ class Capybara::Selenium::MarionetteNode < Capybara::Selenium::Node
|
||||||
native.clear # By default files are appended so we have to clear here
|
native.clear # By default files are appended so we have to clear here
|
||||||
return super if driver.browser.capabilities[:browser_version].to_f >= 62.0
|
return super if driver.browser.capabilities[:browser_version].to_f >= 62.0
|
||||||
|
|
||||||
|
# Workaround lack of support for multiple upload by uploading one at a time
|
||||||
path_names = value.to_s.empty? ? [] : value
|
path_names = value.to_s.empty? ? [] : value
|
||||||
Array(path_names).each do |path|
|
Array(path_names).each do |path|
|
||||||
unless driver.browser.respond_to?(:upload)
|
unless driver.browser.respond_to?(:upload)
|
||||||
|
@ -49,7 +50,7 @@ private
|
||||||
|
|
||||||
def upload(local_file)
|
def upload(local_file)
|
||||||
unless File.file?(local_file)
|
unless File.file?(local_file)
|
||||||
raise Error::WebDriverError, "you may only upload files: #{local_file.inspect}"
|
raise ArgumentError, "You may only upload files: #{local_file.inspect}"
|
||||||
end
|
end
|
||||||
|
|
||||||
result = bridge.http.call(:post, "session/#{bridge.session_id}/file", file: Selenium::WebDriver::Zipper.zip_file(local_file))
|
result = bridge.http.call(:post, "session/#{bridge.session_id}/file", file: Selenium::WebDriver::Zipper.zip_file(local_file))
|
||||||
|
|
|
@ -30,6 +30,10 @@ def ensure_selenium_running!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def selenium_gte?(version)
|
||||||
|
defined?(Selenium::WebDriver::VERSION) && (Selenium::WebDriver::VERSION.to_f >= version)
|
||||||
|
end
|
||||||
|
|
||||||
Capybara.register_driver :selenium_chrome_remote do |app|
|
Capybara.register_driver :selenium_chrome_remote do |app|
|
||||||
ensure_selenium_running!
|
ensure_selenium_running!
|
||||||
|
|
||||||
|
@ -63,7 +67,7 @@ Capybara::SpecHelper.run_specs TestSessions::Chrome, CHROME_REMOTE_DRIVER.to_s,
|
||||||
when 'Capybara::Session selenium_chrome_remote #attach_file with multipart form should not break when using HTML5 multiple file input uploading multiple files',
|
when 'Capybara::Session selenium_chrome_remote #attach_file with multipart form should not break when using HTML5 multiple file input uploading multiple files',
|
||||||
'Capybara::Session selenium_chrome_remote #attach_file with multipart form should fire change once for each set of files uploaded',
|
'Capybara::Session selenium_chrome_remote #attach_file with multipart form should fire change once for each set of files uploaded',
|
||||||
'Capybara::Session selenium_chrome_remote #attach_file with multipart form should fire change once when uploading multiple files from empty'
|
'Capybara::Session selenium_chrome_remote #attach_file with multipart form should fire change once when uploading multiple files from empty'
|
||||||
pending "Selenium with Remote Chrome doesn't support multiple file upload"
|
pending "Selenium with Remote Chrome doesn't support multiple file upload" unless selenium_gte?(3.14)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -39,14 +39,14 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have return code 1 when running selenium_driver_rspec_failure.rb' do
|
it 'should have return code 1 when running selenium_driver_rspec_failure.rb' do
|
||||||
skip if headless_or_remote?
|
skip "only setup for local non-headless" if headless_or_remote?
|
||||||
|
|
||||||
system(@env, 'rspec spec/fixtures/selenium_driver_rspec_failure.rb', out: File::NULL, err: File::NULL)
|
system(@env, 'rspec spec/fixtures/selenium_driver_rspec_failure.rb', out: File::NULL, err: File::NULL)
|
||||||
expect($CHILD_STATUS.exitstatus).to eq(1)
|
expect($CHILD_STATUS.exitstatus).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should have return code 0 when running selenium_driver_rspec_success.rb' do
|
it 'should have return code 0 when running selenium_driver_rspec_success.rb' do
|
||||||
skip if headless_or_remote?
|
skip "only setup for local non-headless" if headless_or_remote?
|
||||||
|
|
||||||
system(@env, 'rspec spec/fixtures/selenium_driver_rspec_success.rb', out: File::NULL, err: File::NULL)
|
system(@env, 'rspec spec/fixtures/selenium_driver_rspec_success.rb', out: File::NULL, err: File::NULL)
|
||||||
expect($CHILD_STATUS.exitstatus).to eq(0)
|
expect($CHILD_STATUS.exitstatus).to eq(0)
|
||||||
|
|
Loading…
Add table
Reference in a new issue