Fix IE test failures
Mark expected IE test failures Use latest iedriverserver in tests
This commit is contained in:
parent
5c8a795e1f
commit
cd8c7ddf6e
1
.rspec
1
.rspec
|
@ -1,4 +1,5 @@
|
|||
--color
|
||||
--require fuubar
|
||||
--format Fuubar
|
||||
# --format documentation
|
||||
--order random
|
|
@ -3,6 +3,8 @@ version: 1.0.{build}-{branch}
|
|||
cache:
|
||||
- vendor/bundle
|
||||
|
||||
# image: Visual Studio 2017
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- RUBY_VERSION: 25
|
||||
|
@ -34,9 +36,14 @@ install:
|
|||
build: off
|
||||
|
||||
before_test:
|
||||
# - ps: Invoke-WebRequest 'https://github.com/SeleniumHQ/selenium/raw/master/cpp/prebuilt/x64/Release/IEDriverServer.exe' -OutFile 'C:\Tools\WebDriver\IEDriverServer.exe'
|
||||
- ps: Invoke-WebRequest 'https://github.com/SeleniumHQ/selenium/raw/master/cpp/prebuilt/Win32/Release/IEDriverServer.exe' -OutFile 'C:\Tools\WebDriver\IEDriverServer.exe'
|
||||
- ruby -v
|
||||
- gem -v
|
||||
- bundle -v
|
||||
- chromedriver.exe --version
|
||||
- geckodriver.exe --version
|
||||
- IEDriverServer.exe --version
|
||||
|
||||
test_script:
|
||||
- bundle exec rake travis
|
|
@ -359,6 +359,8 @@ private
|
|||
when :firefox
|
||||
require 'capybara/selenium/patches/pause_duration_fix' if pause_broken?(sel_driver)
|
||||
extend FirefoxDriver if sel_driver.capabilities.is_a?(::Selenium::WebDriver::Remote::W3C::Capabilities)
|
||||
when :ie, :internet_explorer
|
||||
extend InternetExplorerDriver
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -402,3 +404,4 @@ end
|
|||
|
||||
require 'capybara/selenium/driver_specializations/chrome_driver'
|
||||
require 'capybara/selenium/driver_specializations/firefox_driver'
|
||||
require 'capybara/selenium/driver_specializations/internet_explorer_driver'
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Capybara::Selenium::Driver::InternetExplorerDriver
|
||||
def switch_to_frame(frame)
|
||||
return super unless frame == :parent
|
||||
|
||||
# iedriverserver has an issue if the current frame is removed from within it
|
||||
# so we have to move to the default_content and iterate back through the frames
|
||||
handles = @frame_handles[current_window_handle]
|
||||
browser.switch_to.default_content
|
||||
handles.tap(&:pop).each { |fh| browser.switch_to.frame(fh) }
|
||||
end
|
||||
end
|
|
@ -17,7 +17,6 @@ module Capybara
|
|||
|
||||
def scroll_to(element, location = :top)
|
||||
location, element = element, nil if element.is_a? Symbol
|
||||
|
||||
if element.is_a? Capybara::Selenium::Node
|
||||
scroll_element_to_location(element, location)
|
||||
elsif location.is_a? Symbol
|
||||
|
@ -67,7 +66,7 @@ module Capybara
|
|||
|
||||
def scroll_to_coords(x, y)
|
||||
driver.execute_script <<~JS, self, x, y
|
||||
if (this.scrollTo){
|
||||
if (arguments[0].scrollTo){
|
||||
arguments[0].scrollTo(arguments[1], arguments[2]);
|
||||
} else {
|
||||
arguments[0].scrollTop = arguments[2];
|
||||
|
|
|
@ -3,6 +3,7 @@ $(function() {
|
|||
$('#change').text('I changed it');
|
||||
$('#drag, #drag_scroll, #drag_link').draggable();
|
||||
$('#drop, #drop_scroll').droppable({
|
||||
tolerance: 'touch',
|
||||
drop: function(event, ui) {
|
||||
ui.draggable.remove();
|
||||
$(this).html('Dropped!');
|
||||
|
|
|
@ -13,26 +13,26 @@ Capybara::SpecHelper.spec '#attach_file' do
|
|||
it 'should set a file path by id' do
|
||||
@session.attach_file 'form_image', with_os_path_separators(__FILE__)
|
||||
@session.click_button('awesome')
|
||||
expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
|
||||
expect(extract_results(@session)['image']).to end_with(File.basename(__FILE__))
|
||||
end
|
||||
|
||||
it 'should set a file path by label' do
|
||||
@session.attach_file 'Image', with_os_path_separators(__FILE__)
|
||||
@session.click_button('awesome')
|
||||
expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
|
||||
expect(extract_results(@session)['image']).to end_with(File.basename(__FILE__))
|
||||
end
|
||||
|
||||
it 'should be able to set on element if no locator passed' do
|
||||
ff = @session.find(:file_field, 'Image')
|
||||
ff.attach_file(with_os_path_separators(__FILE__))
|
||||
@session.click_button('awesome')
|
||||
expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
|
||||
expect(extract_results(@session)['image']).to end_with(File.basename(__FILE__))
|
||||
end
|
||||
|
||||
it 'casts to string' do
|
||||
@session.attach_file :form_image, with_os_path_separators(__FILE__)
|
||||
@session.click_button('awesome')
|
||||
expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
|
||||
expect(extract_results(@session)['image']).to end_with(File.basename(__FILE__))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -137,7 +137,7 @@ Capybara::SpecHelper.spec '#attach_file' do
|
|||
it 'should set a file path by partial label when false' do
|
||||
@session.attach_file 'Imag', with_os_path_separators(__FILE__), exact: false
|
||||
@session.click_button('awesome')
|
||||
expect(extract_results(@session)['image']).to eq(File.basename(__FILE__))
|
||||
expect(extract_results(@session)['image']).to end_with(File.basename(__FILE__))
|
||||
end
|
||||
|
||||
it 'should not allow partial matches when true' do
|
||||
|
@ -181,7 +181,7 @@ Capybara::SpecHelper.spec '#attach_file' do
|
|||
end
|
||||
end
|
||||
|
||||
private
|
||||
private
|
||||
|
||||
def with_os_path_separators(path)
|
||||
Gem.win_platform? ? path.to_s.tr('/', '\\') : path.to_s
|
||||
|
|
|
@ -126,7 +126,7 @@ Capybara::SpecHelper.spec '#fill_in' do
|
|||
end
|
||||
|
||||
it 'should fill in a field based on current value' do
|
||||
@session.fill_in(currently_with: 'John', with: 'Thomas')
|
||||
@session.fill_in(id: /form.*name/, currently_with: 'John', with: 'Thomas')
|
||||
@session.click_button('awesome')
|
||||
expect(extract_results(@session)['first_name']).to eq('Thomas')
|
||||
end
|
||||
|
|
|
@ -102,7 +102,7 @@ Capybara::SpecHelper.spec '#find_field' do
|
|||
|
||||
context 'with no locator' do
|
||||
it 'should use options to find the field' do
|
||||
expect(@session.find_field(with: 'dog')['id']).to eq 'form_pets_dog'
|
||||
expect(@session.find_field(type: 'checkbox', with: 'dog')['id']).to eq 'form_pets_dog'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ Capybara::SpecHelper.spec '#switch_to_frame', requires: [:frames] do
|
|||
@session.switch_to_frame frame
|
||||
frame = @session.find(:frame, 'childFrame')
|
||||
@session.switch_to_frame frame
|
||||
|
||||
@session.click_link 'Close Window'
|
||||
@session.switch_to_frame :parent # Go back to parentFrame
|
||||
expect(@session).to have_selector(:css, 'body#parentBody')
|
||||
|
|
|
@ -276,7 +276,7 @@ Capybara::SpecHelper.spec '#has_no_select?' do
|
|||
it 'should support locator-less usage' do
|
||||
expect(@session.has_no_select?(with_options: %w[Norway Sweden Finland Latvia])).to eq true
|
||||
expect(@session).to have_no_select(with_options: ['New London'])
|
||||
expect(@session.has_no_select?(with_selected: ['Boxers'])).to eq true
|
||||
expect(@session).to have_no_select(with_selected: %w[Commando Boxers])
|
||||
expect(@session.has_no_select?(id: 'form_underwear', with_selected: ['Boxers'])).to eq true
|
||||
expect(@session).to have_no_select(id: 'form_underwear', with_selected: %w[Commando Boxers])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -226,7 +226,7 @@ Capybara::SpecHelper.spec '#has_text?' do
|
|||
Capybara.using_wait_time(0.1) do
|
||||
@session.visit('/with_js')
|
||||
@session.click_link('Click me')
|
||||
expect(@session).to have_text('Has been clicked', wait: 2)
|
||||
expect(@session).to have_text('Has been clicked', wait: 3)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,24 +30,24 @@ Capybara::SpecHelper.spec '#scroll_to', requires: [:scroll] do
|
|||
it 'can scroll the window to the vertical top' do
|
||||
@session.scroll_to :bottom
|
||||
@session.scroll_to :top
|
||||
expect(@session.evaluate_script('[window.scrollX, window.scrollY]')).to eq [0, 0]
|
||||
expect(@session.evaluate_script('[window.scrollX || window.pageXOffset, window.scrollY || window.pageYOffset]')).to eq [0, 0]
|
||||
end
|
||||
|
||||
it 'can scroll the window to the vertical bottom' do
|
||||
@session.scroll_to :bottom
|
||||
max_scroll = @session.evaluate_script('document.body.scrollHeight - document.body.clientHeight')
|
||||
expect(@session.evaluate_script('[window.scrollX, window.scrollY]')).to eq [0, max_scroll]
|
||||
expect(@session.evaluate_script('[window.scrollX || window.pageXOffset, window.scrollY || window.pageYOffset]')).to eq [0, max_scroll]
|
||||
end
|
||||
|
||||
it 'can scroll the window to the vertical center' do
|
||||
@session.scroll_to :center
|
||||
max_scroll = @session.evaluate_script('document.documentElement.scrollHeight - document.body.clientHeight')
|
||||
expect(@session.evaluate_script('[window.scrollX, window.scrollY]')).to eq [0, max_scroll / 2]
|
||||
expect(@session.evaluate_script('[window.scrollX || window.pageXOffset, window.scrollY || window.pageYOffset]')).to eq [0, max_scroll / 2]
|
||||
end
|
||||
|
||||
it 'can scroll the window to specifc location' do
|
||||
it 'can scroll the window to specific location' do
|
||||
@session.scroll_to 100, 100
|
||||
expect(@session.evaluate_script('[window.scrollX, window.scrollY]')).to eq [100, 100]
|
||||
expect(@session.evaluate_script('[window.scrollX || window.pageXOffset, window.scrollY || window.pageYOffset]')).to eq [100, 100]
|
||||
end
|
||||
|
||||
it 'can scroll an element to the top of the scrolling element' do
|
||||
|
@ -55,7 +55,7 @@ Capybara::SpecHelper.spec '#scroll_to', requires: [:scroll] do
|
|||
el = scrolling_element.find(:css, '#inner')
|
||||
scrolling_element.scroll_to(el, :top)
|
||||
scrolling_element_top = scrolling_element.evaluate_script('this.getBoundingClientRect().top')
|
||||
expect(el.evaluate_script('this.getBoundingClientRect().top')).to be_within(1).of(scrolling_element_top)
|
||||
expect(el.evaluate_script('this.getBoundingClientRect().top')).to be_within(3).of(scrolling_element_top)
|
||||
end
|
||||
|
||||
it 'can scroll an element to the bottom of the scrolling element' do
|
||||
|
@ -97,7 +97,7 @@ Capybara::SpecHelper.spec '#scroll_to', requires: [:scroll] do
|
|||
expect(scrolling_element.evaluate_script('[this.scrollLeft, this.scrollTop]')).to eq [0, max_scroll / 2]
|
||||
end
|
||||
|
||||
it 'can scroll the scrolling element to specifc location' do
|
||||
it 'can scroll the scrolling element to specific location' do
|
||||
scrolling_element = @session.find(:css, '#scrollable')
|
||||
scrolling_element.scroll_to 100, 100
|
||||
expect(scrolling_element.evaluate_script('[this.scrollLeft, this.scrollTop]')).to eq [100, 100]
|
||||
|
@ -105,8 +105,8 @@ Capybara::SpecHelper.spec '#scroll_to', requires: [:scroll] do
|
|||
|
||||
context 'scroll_by' do
|
||||
it 'can scroll the window by a specifc amount' do
|
||||
@session.scroll_by 100, 100
|
||||
expect(@session.evaluate_script('[window.scrollX, window.scrollY]')).to eq [100, 100]
|
||||
@session.scroll_by 50, 75
|
||||
expect(@session.evaluate_script('[window.scrollX || window.pageXOffset, window.scrollY || window.pageYOffset]')).to eq [50, 75]
|
||||
end
|
||||
|
||||
it 'can scroll the scroll the scrolling element by a specifc amount' do
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<title>with_animation</title>
|
||||
<script src="/jquery.js" type="text/javascript" charset="utf-8"></script>
|
||||
<script>
|
||||
$(document).on('contextmenu', function(e){ e.preventDefault(); })
|
||||
$(document).on('contextmenu', function(e){ e.preventDefault(); });
|
||||
</script>
|
||||
<style>
|
||||
div {
|
||||
|
|
|
@ -21,7 +21,7 @@ Capybara.register_driver :selenium_firefox do |app|
|
|||
app,
|
||||
browser: :firefox,
|
||||
options: browser_options,
|
||||
timeout: 31,
|
||||
timeout: 31
|
||||
# Get a trace level log from geckodriver
|
||||
# :driver_opts => { args: ['-vv'] }
|
||||
)
|
||||
|
|
|
@ -5,6 +5,20 @@ require 'selenium-webdriver'
|
|||
require 'shared_selenium_session'
|
||||
require 'rspec/shared_spec_matchers'
|
||||
|
||||
::Selenium::WebDriver::IE.driver_path = 'C:\Tools\WebDriver\IEDriverServer.exe' if ENV['CI']
|
||||
|
||||
def selenium_host
|
||||
ENV.fetch('SELENIUM_HOST', '192.168.56.102')
|
||||
end
|
||||
|
||||
def selenium_port
|
||||
ENV.fetch('SELENIUM_PORT', 4444)
|
||||
end
|
||||
|
||||
def server_host
|
||||
ENV.fetch('SERVER_HOST', '10.24.4.135')
|
||||
end
|
||||
|
||||
Capybara.register_driver :selenium_ie do |app|
|
||||
# ::Selenium::WebDriver.logger.level = "debug"
|
||||
options = ::Selenium::WebDriver::IE::Options.new
|
||||
|
@ -17,10 +31,36 @@ Capybara.register_driver :selenium_ie do |app|
|
|||
)
|
||||
end
|
||||
|
||||
if ENV['REMOTE']
|
||||
Capybara.register_driver :selenium_ie do |app|
|
||||
url = "http://#{selenium_host}:#{selenium_port}/wd/hub"
|
||||
options = ::Selenium::WebDriver::IE::Options.new
|
||||
options.require_window_focus = true
|
||||
|
||||
Capybara::Selenium::Driver.new(app,
|
||||
browser: :remote,
|
||||
desired_capabilities: ::Selenium::WebDriver::Remote::Capabilities.ie,
|
||||
options: options,
|
||||
url: url).tap do |driver|
|
||||
driver.browser.file_detector = lambda do |args|
|
||||
str = args.first.to_s
|
||||
str if File.exist?(str)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Capybara.server_host = server_host
|
||||
end
|
||||
|
||||
module TestSessions
|
||||
SeleniumIE = Capybara::Session.new(:selenium_ie, TestApp)
|
||||
end
|
||||
|
||||
# TestSessions::SeleniumIE.driver.browser.file_detector = lambda do |args|
|
||||
# str = args.first.to_s
|
||||
# str if File.exist?(str)
|
||||
# end if ENV['REMOTE']
|
||||
|
||||
TestSessions::SeleniumIE.current_window.resize_to(800, 500)
|
||||
|
||||
skipped_tests = %i[response_headers status_code trigger modals hover form_attribute windows]
|
||||
|
@ -41,12 +81,35 @@ Capybara::SpecHelper.run_specs TestSessions::SeleniumIE, 'selenium', capybara_sk
|
|||
skip 'IE 11 obeys non-standard disabled attribute on anchor tag'
|
||||
when /#right_click should allow modifiers$/
|
||||
skip "Windows can't :meta click because :meta triggers start menu"
|
||||
when /#click should allow modifiers$/
|
||||
pending "Doesn't work with IE for some unknown reason$"
|
||||
when /#double_click should allow modifiers$/
|
||||
pending "Doesn't work with IE for some unknown reason$"
|
||||
when /#click should allow multiple modifiers$/
|
||||
skip "Windows can't :meta click because :meta triggers start menu"
|
||||
when /#double_click should allow multiple modifiers$/
|
||||
skip "Windows can't :alt double click due to being properties shortcut"
|
||||
when /via clicking the wrapping label if possible$/
|
||||
pending 'IEDriver has an issue with the click location of elements with multiple children if the first child is a text node and the page is scrolled'
|
||||
when /#has_css\? should support case insensitive :class and :id options$/
|
||||
pending "IE doesn't support case insensitive CSS selectors"
|
||||
when /#reset_session! removes ALL cookies$/
|
||||
pending "IE driver doesn't provide a way to remove ALL cookies"
|
||||
when /#click_button should send button in document order$/
|
||||
pending "IE 11 doesn't support the 'form' attribute"
|
||||
when /#click_button should follow permanent redirects that maintain method$/
|
||||
pending "Window 7 and 8.1 don't support 308 http status code"
|
||||
when /#scroll_to can scroll an element to the center of the viewport$/,
|
||||
/#scroll_to can scroll an element to the center of the scrolling element$/
|
||||
pending " IE doesn't support ScrollToOptions"
|
||||
when /#attach_file with multipart form should fire change once for each set of files uploaded$/,
|
||||
/#attach_file with multipart form should fire change once when uploading multiple files from empty$/,
|
||||
/#attach_file with multipart form should not break when using HTML5 multiple file input uploading multiple files$/
|
||||
pending "IE requires all files be uploaded from same directory. Selenium doesn't provide that." if ENV['REMOTE']
|
||||
when %r{#attach_file with multipart form should send content type image/jpeg when uploading an image$}
|
||||
pending 'IE gets text/plain type for some reason'
|
||||
when /#click should not retry clicking when wait is disabled$/
|
||||
pending "IE driver doesn't error when clicking on covered elements, it just clicks the wrong element"
|
||||
when /#click should go to the same page if href is blank$/
|
||||
pending 'IE treats blank href as a parent request (against HTML spec)'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -58,13 +121,16 @@ end
|
|||
|
||||
RSpec.describe Capybara::Selenium::Node do
|
||||
it '#right_click should allow modifiers' do
|
||||
# pending "Actions API doesn't appear to work for this"
|
||||
session = TestSessions::SeleniumIE
|
||||
session.visit('/with_js')
|
||||
session.find(:css, '#click-test').right_click(:control)
|
||||
el = session.find(:css, '#click-test')
|
||||
el.right_click(:control)
|
||||
expect(session).to have_link('Has been control right clicked')
|
||||
end
|
||||
|
||||
it '#click should allow multiple modifiers' do
|
||||
# pending "Actions API doesn't appear to work for this"
|
||||
session = TestSessions::SeleniumIE
|
||||
session.visit('with_js')
|
||||
# IE triggers system behavior with :meta so can't use those here
|
||||
|
@ -73,6 +139,7 @@ RSpec.describe Capybara::Selenium::Node do
|
|||
end
|
||||
|
||||
it '#double_click should allow modifiers' do
|
||||
# pending "Actions API doesn't appear to work for this"
|
||||
session = TestSessions::SeleniumIE
|
||||
session.visit('/with_js')
|
||||
session.find(:css, '#click-test').double_click(:shift)
|
||||
|
|
|
@ -339,6 +339,7 @@ RSpec.shared_examples 'Capybara::Session' do |session, mode|
|
|||
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']
|
||||
pending "IE doesn't support uploading a directory" if ie?(session)
|
||||
|
||||
session.visit('/form')
|
||||
@test_file_dir = File.expand_path('./fixtures', File.dirname(__FILE__))
|
||||
|
|
|
@ -51,6 +51,6 @@ end
|
|||
|
||||
RSpec.configure do |config|
|
||||
Capybara::SpecHelper.configure(config)
|
||||
config.filter_run_including focus_: true # unless ENV['CI']
|
||||
config.filter_run_including focus_: true unless ENV['CI']
|
||||
config.run_all_when_everything_filtered = true
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue