Module: SeleniumWrapperJsErrors

Extended by:
Gem::Deprecate
Included in:
OnlyofficeDocumentserverTestingFramework::SeleniumWrapper
Defined in:
lib/onlyoffice_documentserver_testing_framework/selenium_wrapper/selenium_wrapper_js_errors.rb

Overview

Module for working with selenium wrapper JavaScript Errors

Instance Method Summary collapse

Instance Method Details

#console_errorsArray<String> Also known as: get_console_errors

Returns list of current console errors.

Returns:

  • (Array<String>)

    list of current console errors



26
27
28
29
30
31
32
# File 'lib/onlyoffice_documentserver_testing_framework/selenium_wrapper/selenium_wrapper_js_errors.rb', line 26

def console_errors
  severe_error = []
  @instance.webdriver.browser_logs.each do |log|
    severe_error << log.message if log.level.include?('SEVERE') && !error_ignored?(log.message)
  end
  severe_error
end

#error_ignored?(error_message) ⇒ True, False

Should current error be ignored

Parameters:

  • error_message (String)

    current error

Returns:

  • (True, False)

    should be ignored?



18
19
20
21
22
23
# File 'lib/onlyoffice_documentserver_testing_framework/selenium_wrapper/selenium_wrapper_js_errors.rb', line 18

def error_ignored?(error_message)
  return true if ignored_errors.any? { |word| error_message.include?(word) }
  return true if @instance.env_options['IgnoredJSErrors'].any? { |word| error_message.include?(word) }

  false
end

#fail_if_console_errorObject

Fail if any JS error happened



39
40
41
42
43
44
45
# File 'lib/onlyoffice_documentserver_testing_framework/selenium_wrapper/selenium_wrapper_js_errors.rb', line 39

def fail_if_console_error
  errors = console_errors
  return if errors.empty?

  @instance.webdriver.webdriver_error(Selenium::WebDriver::Error::JavascriptError,
                                      "There are some errors in the Web Console: #{errors}")
end

#ignored_errorsArray<String>

Returns list of errors should be ignored.

Returns:

  • (Array<String>)

    list of errors should be ignored



6
7
8
9
10
11
12
13
# File 'lib/onlyoffice_documentserver_testing_framework/selenium_wrapper/selenium_wrapper_js_errors.rb', line 6

def ignored_errors
  return @ignored_errors if @ignored_errors

  @ignored_errors = File.readlines("#{File.expand_path('..', __dir__)}" \
                                   '/selenium_wrapper/selenium_wrapper_js_errors' \
                                   '/ignored_errors.list')
                        .map(&:strip)
end