From a18b0359524343abb3a51f7284c6bf6d95115753 Mon Sep 17 00:00:00 2001 From: Jens Kraemer Date: Fri, 16 Oct 2020 09:18:50 +0800 Subject: [PATCH] fix chrome options key for system tests and remove corresponding workaround as posted in https://github.com/SeleniumHQ/selenium/issues/5292#issuecomment-388810585 changing the key to goog:chromeOptions fixes the issue Unfortunately it is unclear to me if we have to retain the old 'chromeOptions' key for windows support and I have no way to try this out. https://chromedriver.chromium.org/capabilities also uses the 'goog:' prefix in examples without mentioning any specific platform so I think it will just work. --- test/application_system_test_case.rb | 9 +++------ test/system/issues_test.rb | 4 +--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 7f6097cee..605424fc7 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -26,7 +26,7 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase :selenium, using: :chrome, screen_size: [1024, 900], options: { desired_capabilities: Selenium::WebDriver::Remote::Capabilities.chrome( - 'chromeOptions' => { + 'goog:chromeOptions' => { 'prefs' => { 'download.default_directory' => DOWNLOADS_PATH, 'download.prompt_for_download' => false, @@ -62,14 +62,11 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase end def clear_downloaded_files - # https://github.com/SeleniumHQ/selenium/issues/5292 - FileUtils.rm downloaded_files if Redmine::Platform.mswin? + FileUtils.rm downloaded_files end def downloaded_files(filename='*') - # https://github.com/SeleniumHQ/selenium/issues/5292 - downloaded_path = Redmine::Platform.mswin? ? DOWNLOADS_PATH : "#{ENV['HOME']}/Downloads" - Dir.glob("#{downloaded_path}/#{filename}"). + Dir.glob("#{DOWNLOADS_PATH}/#{filename}"). reject{|f| f=~/\.(tmp|crdownload)$/}.sort_by{|f| File.mtime(f)} end diff --git a/test/system/issues_test.rb b/test/system/issues_test.rb index 046088751..94d39c158 100644 --- a/test/system/issues_test.rb +++ b/test/system/issues_test.rb @@ -519,9 +519,7 @@ class IssuesSystemTest < ApplicationSystemTestCase click_on 'CSV' click_on 'Export' - # https://github.com/SeleniumHQ/selenium/issues/5292 - # if issues.csv exists, Chrome creates issues (1).csv, issues (2).csv ... - csv = CSV.read(downloaded_file("issues*.csv")) + csv = CSV.read(downloaded_file("issues.csv")) subject_index = csv.shift.index('Subject') subjects = csv.map {|row| row[subject_index]} assert_equal subjects.sort, subjects -- 2.20.1