summaryrefslogtreecommitdiff
path: root/spec/support/capybara.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/capybara.rb')
-rw-r--r--spec/support/capybara.rb22
1 files changed, 17 insertions, 5 deletions
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
index 38f9ccf23f5..66fce4fddf1 100644
--- a/spec/support/capybara.rb
+++ b/spec/support/capybara.rb
@@ -9,6 +9,9 @@ require 'selenium-webdriver'
# Give CI some extra time
timeout = ENV['CI'] || ENV['CI_SERVER'] ? 60 : 30
+# Support running Capybara on a specific port to allow saving commonly used pages
+Capybara.server_port = ENV['CAPYBARA_PORT'] if ENV['CAPYBARA_PORT']
+
# Define an error class for JS console messages
JSConsoleError = Class.new(StandardError)
@@ -153,11 +156,20 @@ RSpec.configure do |config|
# fixed. If we raised the `JSException` the fixed test would be marked as
# failed again.
if example.exception && !example.exception.is_a?(RSpec::Core::Pending::PendingExampleFixedError)
- console = page.driver.browser.manage.logs.get(:browser)&.reject { |log| log.message =~ JS_CONSOLE_FILTER }
-
- if console.present?
- message = "Unexpected browser console output:\n" + console.map(&:message).join("\n")
- raise JSConsoleError, message
+ begin
+ console = page.driver.browser.manage.logs.get(:browser)&.reject { |log| log.message =~ JS_CONSOLE_FILTER }
+
+ if console.present?
+ message = "Unexpected browser console output:\n" + console.map(&:message).join("\n")
+ raise JSConsoleError, message
+ end
+ rescue Selenium::WebDriver::Error::WebDriverError => error
+ if error.message =~ /unknown command: session\/[0-9a-zA-Z]+(?:\/se)?\/log/
+ message = "Unable to access Chrome javascript console logs. You may be using an outdated version of ChromeDriver."
+ raise JSConsoleError, message
+ else
+ raise error
+ end
end
end