From dc5a6b58e6bad3c09942aba56fd88b2c143a701d Mon Sep 17 00:00:00 2001 From: Daria Mayorova Date: Tue, 30 Jul 2024 18:25:56 +0200 Subject: [PATCH] Fix performance logs issue --- features/support/hooks.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/features/support/hooks.rb b/features/support/hooks.rb index 5cc8e82cea..6745f353c3 100644 --- a/features/support/hooks.rb +++ b/features/support/hooks.rb @@ -118,11 +118,13 @@ line_number = scenario.location.line.to_s # Network logs - if page.driver.browser.respond_to?(:manage) + if page.driver.browser.respond_to?(:logs) # performance logs may fail if this logging type is not configured or not supported by driver - if page.driver.browser.manage.logs.available_types.include? :performance - logs = page.driver.browser.manage.logs.get(:performance) - array = logs.each_with_object([]) do |entry, messages| + logs = page.driver.browser.logs + + if logs.available_types.include? :performance + perf_logs = logs.get(:performance) + array = perf_logs.each_with_object([]) do |entry, messages| message = JSON.parse(entry.message) # next unless message.dig('message', 'params', 'documentURL').to_s.end_with? '/p/login' messages << message @@ -139,11 +141,11 @@ console_log = folder.join("#{line_number}.log") - if (logs = page.driver.browser.manage.logs.get(:browser)).present? - entries = logs.map{ |entry| "[#{entry.level}] #{entry.message}" } + if (browser_logs = logs.get(:browser)).present? + entries = browser_logs.map { |entry| "[#{entry.level}] #{entry.message}" } console_log.open('w') do |f| - f.puts *entries + f.puts(*entries) end print "Saved console log to #{console_log}\n"