Skip to content

Commit

Permalink
QE: handle errors occurring during a page reload (#8110)
Browse files Browse the repository at this point in the history
  • Loading branch information
NamelessOne91 authored Jan 31, 2024
1 parent 1844a57 commit 2187c60
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 50 deletions.
10 changes: 2 additions & 8 deletions testsuite/features/step_definitions/common_steps.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2010-2023 SUSE LLC.
# Copyright (c) 2010-2024 SUSE LLC.
# Licensed under the terms of the MIT license.

### This file contains all step definitions concerning general product funtionality
Expand Down Expand Up @@ -186,13 +186,7 @@
rescue Capybara::ElementNotFound
# ignored - pending actions cannot be found
end
begin
accept_prompt do
execute_script 'window.location.reload()'
end
rescue Capybara::ModalNotFound
# ignored
end
refresh_page
end
end

Expand Down
41 changes: 6 additions & 35 deletions testsuite/features/step_definitions/navigation_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,7 @@
repeat_until_timeout(message: "Couldn't find text '#{text}'") do
break if has_content?(text, wait: 3)

begin
accept_prompt do
execute_script 'window.location.reload()'
end
rescue Capybara::ModalNotFound
# ignored
end
refresh_page
end
end

Expand All @@ -75,13 +69,7 @@
repeat_until_timeout(message: "I still see text '#{text}'", timeout: seconds.to_i) do
break if has_no_text?(text, wait: 3)

begin
accept_prompt do
execute_script 'window.location.reload()'
end
rescue Capybara::ModalNotFound
# ignored
end
refresh_page
end
end

Expand All @@ -106,13 +94,8 @@
log "#{current} Still waiting for action to complete..."
last = current
end
begin
accept_prompt do
execute_script 'window.location.reload()'
end
rescue Capybara::ModalNotFound
# ignored
end

refresh_page
end
end

Expand All @@ -136,13 +119,7 @@
repeat_until_timeout(message: "Text '#{text}' is still visible") do
break unless has_content?(text, wait: 3)

begin
accept_prompt do
execute_script 'window.location.reload()'
end
rescue Capybara::ModalNotFound
# ignored
end
refresh_page
end
end

Expand All @@ -157,13 +134,7 @@

# If the connection failed try reloading since the VM may not have been ready
if find(:xpath, '//*[contains(@class, "modal-title") and text() = "Failed to connect"]')
begin
accept_prompt do
execute_script 'window.location.reload()'
end
rescue Capybara::ModalNotFound
# ignored
end
refresh_page
end
end
end
Expand Down
8 changes: 1 addition & 7 deletions testsuite/features/step_definitions/setup_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,7 @@
repeat_until_timeout(message: "Couldn't find checked radio button #{arg1}") do
break if has_checked_field?(arg1)

begin
accept_prompt do
execute_script 'window.location.reload()'
end
rescue Capybara::ModalNotFound
# ignored
end
refresh_page
end
end
end
Expand Down
8 changes: 8 additions & 0 deletions testsuite/features/support/commonlib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ def format_detail(message, last_result, report_result)
"#{formatted_message}#{formatted_result}"
end

def refresh_page
accept_prompt do
execute_script 'window.location.reload()'
end
rescue Capybara::ModalNotFound
# ignored
end

def click_button_and_wait(locator = nil, **options)
click_button(locator, options)
begin
Expand Down
2 changes: 2 additions & 0 deletions testsuite/features/support/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ def capybara_register_driver
path = "screenshots/#{scenario.name.tr(' ./', '_')}.png"
# only click on Details when we have errors during bootstrapping and more Details available
click_button('Details') if has_content?('Bootstrap Minions') && has_content?('Details')
# a TimeoutError may be raised while a page is still (re)loading
find('#page-body', wait: 3) if scenario.exception.is_a?(TimeoutError)
page.driver.browser.save_screenshot(path)
attach path, 'image/png'
attach "#{Time.at(@scenario_start_time).strftime('%H:%M:%S:%L')} - #{Time.at(current_epoch).strftime('%H:%M:%S:%L')} | Current URL: #{current_url}", 'text/plain'
Expand Down

0 comments on commit 2187c60

Please sign in to comment.