Skip to content

Commit

Permalink
add logging to retry
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevma50287 committed Oct 25, 2024
1 parent e1967fa commit d9705f0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions spec/support/correspondence_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,12 @@ def inbound_ops_team_admin_setup
end

def retry_if_not_found(max_attempts: 3, cleanup: nil)
attempts = 0
attempts ||= 0
begin
yield
rescue Capybara::ElementNotFound
rescue Capybara::ElementNotFound => e
attempts += 1
Rails.logger.warn("#{e} caught. Retry attempt: #{attempts}")
cleanup&.call
retry if attempts < max_attempts
end
Expand Down

0 comments on commit d9705f0

Please sign in to comment.