From 7f4c540fa06f0ebfd9395fe33d9dfa561b85798c Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Sun, 3 Jun 2018 17:10:22 +0200 Subject: [PATCH] Retry on stale element reference to avoid race conditions while interface is not ready yet. --- test/browser_test_helper.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 8115df073..b53a5e477 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -570,6 +570,8 @@ class TestCase < Test::Unit::TestCase =end def exists(params) + retries ||= 0 + switch_window_focus(params) log('exists', params) @@ -589,6 +591,10 @@ class TestCase < Test::Unit::TestCase end true + rescue Selenium::WebDriver::Error::StaleElementReferenceError + sleep retries + retries += 1 + retry if retries < 3 end =begin