2018-03-17 07:55:00 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
2018-07-10 17:18:39 -04:00
|
|
|
require 'selenium-webdriver'
|
2018-03-17 07:55:00 -04:00
|
|
|
require 'shared_selenium_session'
|
|
|
|
require 'rspec/shared_spec_matchers'
|
|
|
|
|
2019-04-26 14:42:32 -04:00
|
|
|
if ENV['CI']
|
|
|
|
if ::Selenium::WebDriver::Service.respond_to? :driver_path=
|
|
|
|
::Selenium::WebDriver::IE::Service
|
|
|
|
else
|
|
|
|
::Selenium::WebDriver::IE
|
|
|
|
end.driver_path = 'C:\Tools\WebDriver\IEDriverServer.exe'
|
|
|
|
end
|
2018-12-20 15:37:14 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-03-17 07:55:00 -04:00
|
|
|
Capybara.register_driver :selenium_ie do |app|
|
|
|
|
# ::Selenium::WebDriver.logger.level = "debug"
|
2018-08-29 20:33:51 -04:00
|
|
|
options = ::Selenium::WebDriver::IE::Options.new
|
2019-04-26 14:42:32 -04:00
|
|
|
# options.require_window_focus = true
|
2019-01-08 14:39:38 -05:00
|
|
|
# options.add_option("log", {"level": "trace"})
|
2018-03-17 07:55:00 -04:00
|
|
|
|
2019-01-08 14:39:38 -05:00
|
|
|
if ENV['REMOTE']
|
|
|
|
Capybara.server_host = server_host
|
2018-12-20 15:37:14 -05:00
|
|
|
|
2019-01-08 14:39:38 -05:00
|
|
|
url = "http://#{selenium_host}:#{selenium_port}/wd/hub"
|
2018-12-20 15:37:14 -05:00
|
|
|
Capybara::Selenium::Driver.new(app,
|
|
|
|
browser: :remote,
|
|
|
|
options: options,
|
|
|
|
url: url).tap do |driver|
|
2019-01-08 14:39:38 -05:00
|
|
|
puts driver.browser.capabilities.inspect
|
2018-12-20 15:37:14 -05:00
|
|
|
driver.browser.file_detector = lambda do |args|
|
|
|
|
str = args.first.to_s
|
|
|
|
str if File.exist?(str)
|
|
|
|
end
|
|
|
|
end
|
2019-01-08 14:39:38 -05:00
|
|
|
else
|
|
|
|
Capybara::Selenium::Driver.new(
|
|
|
|
app,
|
|
|
|
browser: :ie,
|
|
|
|
options: options
|
|
|
|
).tap do |driver|
|
|
|
|
puts driver.browser.capabilities.inspect
|
|
|
|
end
|
2018-12-20 15:37:14 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-03-17 07:55:00 -04:00
|
|
|
module TestSessions
|
|
|
|
SeleniumIE = Capybara::Session.new(:selenium_ie, TestApp)
|
|
|
|
end
|
|
|
|
|
2018-08-30 19:42:48 -04:00
|
|
|
TestSessions::SeleniumIE.current_window.resize_to(800, 500)
|
|
|
|
|
2018-04-03 16:08:50 -04:00
|
|
|
skipped_tests = %i[response_headers status_code trigger modals hover form_attribute windows]
|
2018-03-17 07:55:00 -04:00
|
|
|
|
2019-04-19 15:22:17 -04:00
|
|
|
Capybara::SpecHelper.log_selenium_driver_version(Selenium::WebDriver::IE) if ENV['CI']
|
2018-03-17 07:55:00 -04:00
|
|
|
|
2018-07-30 13:37:47 -04:00
|
|
|
TestSessions::SeleniumIE.current_window.resize_to(1600, 1200)
|
|
|
|
|
2018-07-10 17:18:39 -04:00
|
|
|
Capybara::SpecHelper.run_specs TestSessions::SeleniumIE, 'selenium', capybara_skip: skipped_tests do |example|
|
2018-07-30 13:37:47 -04:00
|
|
|
case example.metadata[:full_description]
|
2018-07-05 14:50:43 -04:00
|
|
|
when /#refresh it reposts$/
|
2018-08-14 17:37:24 -04:00
|
|
|
skip 'IE insists on prompting without providing a way to suppress'
|
2018-07-30 13:37:47 -04:00
|
|
|
when /#click_link can download a file$/
|
|
|
|
skip 'Not sure how to configure IE for automatic downloading'
|
|
|
|
when /#fill_in with Date /
|
|
|
|
pending "IE 11 doesn't support date input types"
|
|
|
|
when /#click_link_or_button with :disabled option happily clicks on links which incorrectly have the disabled attribute$/
|
2018-08-29 20:33:51 -04:00
|
|
|
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"
|
2018-12-20 15:37:14 -05:00
|
|
|
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$"
|
2018-08-29 20:33:51 -04:00
|
|
|
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"
|
2018-12-20 15:37:14 -05:00
|
|
|
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'
|
2019-01-08 14:39:38 -05:00
|
|
|
# when /#click should not retry clicking when wait is disabled$/
|
|
|
|
# Fixed in IEDriverServer 3.141.0.5
|
|
|
|
# pending "IE driver doesn't error when clicking on covered elements, it just clicks the wrong element"
|
2018-12-20 15:37:14 -05:00
|
|
|
when /#click should go to the same page if href is blank$/
|
|
|
|
pending 'IE treats blank href as a parent request (against HTML spec)'
|
2019-04-26 14:42:32 -04:00
|
|
|
when /#attach_file with a block/
|
|
|
|
skip 'Hangs IE testing for unknown reason'
|
2018-07-05 14:50:43 -04:00
|
|
|
end
|
|
|
|
end
|
2018-03-17 07:55:00 -04:00
|
|
|
|
2018-08-31 16:33:42 -04:00
|
|
|
RSpec.describe 'Capybara::Session with Internet Explorer', capybara_skip: skipped_tests do # rubocop:disable RSpec/MultipleDescribes
|
2018-03-17 07:55:00 -04:00
|
|
|
include Capybara::SpecHelper
|
2018-07-10 17:18:39 -04:00
|
|
|
include_examples 'Capybara::Session', TestSessions::SeleniumIE, :selenium_ie
|
2018-03-25 12:50:32 -04:00
|
|
|
include_examples Capybara::RSpecMatchers, TestSessions::SeleniumIE, :selenium_ie
|
2018-03-17 07:55:00 -04:00
|
|
|
end
|
2018-08-29 20:33:51 -04:00
|
|
|
|
|
|
|
RSpec.describe Capybara::Selenium::Node do
|
|
|
|
it '#right_click should allow modifiers' do
|
2018-12-20 15:37:14 -05:00
|
|
|
# pending "Actions API doesn't appear to work for this"
|
2018-08-29 20:33:51 -04:00
|
|
|
session = TestSessions::SeleniumIE
|
|
|
|
session.visit('/with_js')
|
2018-12-20 15:37:14 -05:00
|
|
|
el = session.find(:css, '#click-test')
|
|
|
|
el.right_click(:control)
|
2018-08-29 20:33:51 -04:00
|
|
|
expect(session).to have_link('Has been control right clicked')
|
|
|
|
end
|
|
|
|
|
|
|
|
it '#click should allow multiple modifiers' do
|
2018-12-20 15:37:14 -05:00
|
|
|
# pending "Actions API doesn't appear to work for this"
|
2018-08-29 20:33:51 -04:00
|
|
|
session = TestSessions::SeleniumIE
|
|
|
|
session.visit('with_js')
|
|
|
|
# IE triggers system behavior with :meta so can't use those here
|
|
|
|
session.find(:css, '#click-test').click(:ctrl, :shift, :alt)
|
|
|
|
expect(session).to have_link('Has been alt control shift clicked')
|
|
|
|
end
|
|
|
|
|
|
|
|
it '#double_click should allow modifiers' do
|
2018-12-20 15:37:14 -05:00
|
|
|
# pending "Actions API doesn't appear to work for this"
|
2018-08-29 20:33:51 -04:00
|
|
|
session = TestSessions::SeleniumIE
|
|
|
|
session.visit('/with_js')
|
|
|
|
session.find(:css, '#click-test').double_click(:shift)
|
2018-08-30 19:42:48 -04:00
|
|
|
expect(session).to have_link('Has been shift double clicked')
|
2018-08-29 20:33:51 -04:00
|
|
|
end
|
|
|
|
end
|