Maintenance: Switch to Selenium 4.

This commit is contained in:
Martin Gruner 2022-03-01 11:26:51 +01:00
parent 26e833cace
commit b6151cb0da
5 changed files with 34 additions and 22 deletions

View file

@ -22,17 +22,15 @@
variables:
REMOTE_URL: "http://selenium-firefox:4444/wd/hub"
BROWSER: "firefox"
# Settings for Selenium 3:
NODE_MAX_INSTANCES: "5"
NODE_MAX_SESSION: "5"
SE_NODE_MAX_SESSIONS: "5"
SE_NODE_OVERRIDE_MAX_SESSIONS: "true"
.variables_selenium_chrome: &variables_selenium_chrome
variables:
REMOTE_URL: "http://selenium-chrome:4444/wd/hub"
BROWSER: chrome
# Settings for Selenium 3:
NODE_MAX_INSTANCES: "5"
NODE_MAX_SESSION: "5"
SE_NODE_MAX_SESSIONS: "5"
SE_NODE_OVERRIDE_MAX_SESSIONS: "true"
.variables_app_restart_cmd: &variables_app_restart_cmd
variables:
@ -86,11 +84,11 @@
alias: elasticsearch
.docker_selenium_chrome: &docker_selenium_chrome
name: $CI_REGISTRY/docker/zammad-selenium-chrome:stable
name: $CI_REGISTRY/docker/zammad-selenium-chrome:4
alias: selenium-chrome
.docker_selenium_firefox: &docker_selenium_firefox
name: $CI_REGISTRY/docker/zammad-selenium-firefox:stable
name: $CI_REGISTRY/docker/zammad-selenium-firefox:4
alias: selenium-firefox
.docker_imap: &docker_imap

View file

@ -9,7 +9,7 @@ otrs_chrome:
services:
- name: $CI_REGISTRY/docker/zammad-postgresql:stable
alias: postgresql
- name: $CI_REGISTRY/docker/zammad-selenium-chrome:stable
- name: $CI_REGISTRY/docker/zammad-selenium-chrome:4
alias: selenium-chrome
- name: $CI_REGISTRY/docker/zammad-ci-otrsimport-db:otrs6
alias: zammad-ci-otrsimport-db

View file

@ -152,6 +152,16 @@ module CapybaraCustomExtensions
def page(...)
ZammadCapybaraSessionDelegator.new(element: super, context: self)
end
# Work around an issue with failures in Capybara if different specs of the same rspec run
# use using_session with the same name, e.g. :second_browser. Solve by prepending the test name.
def using_session(name_or_session, &block)
if !(name_or_session.is_a? Capybara::Session)
# self.class.name refers to the RSpec test case.
name_or_session = (self.class.name + "::#{name_or_session}").to_sym
end
Capybara.using_session(name_or_session, &block)
end
end
RSpec.configure do |config|

View file

@ -60,3 +60,16 @@ Capybara.register_driver(:zammad_firefox) do |app|
driver.browser.file_detector = nil if ENV['REMOTE_URL'].present?
end
end
class Capybara::Selenium::Driver
alias original_quit quit
def quit
original_quit
rescue Selenium::WebDriver::Error::ServerError
# Work around a possible capybara/Selenium bug. driver.quit() fails because there is already no session any more;
# not sure why that happens.
ensure
@browser = nil
end
end

View file

@ -64,22 +64,13 @@ RSpec.describe 'System > Translations', type: :system do
visit '/#system/translation'
def toggle_inline_translations
if Gem::Platform.local.os.eql? 'darwin'
page.send_keys [:control, :alt, 't']
else
page.send_keys [:control, :shift, 't']
end
page.send_keys [*hot_keys, 't']
end
toggle_inline_translations
span = find '.sidebar span.translation[title="Overviews"]'
# Move cursor to the end of the string.
if Gem::Platform.local.os.eql? 'darwin'
span.send_keys %i[command right], '_modified', :tab
else
span.send_keys %i[control right], '_modified', :tab
end
span.native.send_keys 'translation_modified', :tab
# Leave the span to be able to turn off inline translations again
visit '/#dashboard'
@ -87,8 +78,8 @@ RSpec.describe 'System > Translations', type: :system do
visit '/#system/translation'
expect(page).to have_no_css('.sidebar span.translation[title="Overviews"]')
expect(find('a[href="#manage/overviews"]')).to have_text("#{overviews_translated}_modified")
expect(find('.content.active input.js-Item[data-source="Overviews"]').value).to eq("#{overviews_translated}_modified")
expect(find('a[href="#manage/overviews"]')).to have_text('translation_modified').and(have_text(overviews_translated))
expect(find('.content.active input.js-Item[data-source="Overviews"]').value).to have_text('translation_modified').and(have_text(overviews_translated))
end
end