From 201027d23c6a6bc4800fe487a42bc0118f8286c2 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Sun, 2 Feb 2020 16:40:13 +0100 Subject: [PATCH] Maintenance: Update selenium to latest compatible version. Current issue with latest: Chrome crashes in chat test when reloading page. --- .gitlab-ci.yml | 4 +- .../browser/agent_ticket_task_changed_test.rb | 6 +-- .../browser/maintenance_login_message_test.rb | 4 ++ test/browser_test_helper.rb | 42 +++++++++++++++---- 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1af3c82a1..f58aa6d21 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -350,7 +350,7 @@ browser:build: alias: postgresql - name: registry.znuny.com/docker/zammad-elasticsearch:stable alias: elasticsearch - - name: docker.io/elgalu/selenium:3.14.0-p17 + - name: docker.io/elgalu/selenium:3.141.59-p32 alias: selenium - name: registry.znuny.com/docker/docker-imap-devel:latest alias: mail @@ -549,7 +549,7 @@ test:browser:core:chrome_6: services: - name: registry.znuny.com/docker/zammad-postgresql:latest alias: postgresql - - name: docker.io/elgalu/selenium:3.14.0-p17 + - name: docker.io/elgalu/selenium:3.141.59-p32 alias: selenium .test_browser_integration_template: &test_browser_integration_definition diff --git a/test/browser/agent_ticket_task_changed_test.rb b/test/browser/agent_ticket_task_changed_test.rb index 7a4b05fbb..8b078754c 100644 --- a/test/browser/agent_ticket_task_changed_test.rb +++ b/test/browser/agent_ticket_task_changed_test.rb @@ -4,7 +4,7 @@ class AgentTicketTaskChangedTest < TestCase # regression test for issue #2042 - incorrect notification when closing a tab after setting up an object def test_detection_of_ticket_update_after_new_attribute - @browser = instance = browser_instance + @browser = browser_instance login( username: 'master@example.com', password: 'test', @@ -35,9 +35,7 @@ class AgentTicketTaskChangedTest < TestCase # verify the 'Discard your changes' message does not appear (since there are no changes) assert_nil execute(js: "return $('.content.active .js-attributeBar .js-reset:not(\".hide\")').get(0)") - # try and close the existing open ticket window - instance.action.move_to(instance.find_elements(css: '#navigation .tasks .task:first-child')[0]).release.perform - instance.find_elements(css: '#navigation .tasks .task:first-child .js-close')[0].click + tasks_close_all() sleep 0.5 exists_not( css: '.modal') diff --git a/test/browser/maintenance_login_message_test.rb b/test/browser/maintenance_login_message_test.rb index e5906f250..3930bf397 100644 --- a/test/browser/maintenance_login_message_test.rb +++ b/test/browser/maintenance_login_message_test.rb @@ -37,6 +37,10 @@ class MaintenanceLoginMessageTest < TestCase browser: browser2, url: browser_url, ) + watch_for( + browser: browser2, + css: '.login', + ) exists_not( browser: browser2, css: '.js-maintenanceLogin', diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 80d2e48cd..8f20774f4 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -353,9 +353,25 @@ class TestCase < ActiveSupport::TestCase end return if !clues - instance.execute_script("$('.js-modal--clue .js-close').click()") + checks = 25 + previous = clues.location + (checks + 1).times do |check| + raise "Element still moving after #{checks} checks" if check == checks + + current = clues.location + sleep 0.2 if ENV['CI'] + break if previous == current + + previous = current + end + clues.click + + watch_for_disappear( + browser: instance, + css: 'modal-backdrop js-backdrop', + ) + assert(true, 'clues closed') - sleep 1 end =begin @@ -752,11 +768,18 @@ class TestCase < ActiveSupport::TestCase instance = params[:browser] || @browser - element = instance.find_elements(css: params[:css])[0] - if !params[:no_click] - element.click + begin + retries ||= 0 + element = instance.find_elements(css: params[:css])[0] + if !params[:no_click] + element.click + end + element.clear + rescue Selenium::WebDriver::Error::StaleElementReferenceError + sleep retries + retries += 1 + retry if retries < 3 end - element.clear begin if !params[:slow] @@ -1596,8 +1619,13 @@ wait untill text in selector disabppears break end rescue - # try again + # Firefox doesn't move the mouse if it's already at the position. + # Therefore the hover event is not triggered in all cases. + # That's why we move the mouse a bit as a workaround and try again. + # The last working selenium version was: https://github.com/elgalu/docker-selenium/releases/tag/3.14.0-p17 + instance.action.move_by(100, 100).perform + # try again end assert(true, 'all tasks closed') end