From 3d4d5414f125a7eede11c39a4529b536aed8c1bf Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 8 Oct 2018 15:51:58 +0200 Subject: [PATCH] Fixed stuck CI env: Organization search results in endless loop while creating a user because ES is not ready yet. --- test/browser_test_helper.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/test/browser_test_helper.rb b/test/browser_test_helper.rb index 9c3ad60cb..5e7a75410 100644 --- a/test/browser_test_helper.rb +++ b/test/browser_test_helper.rb @@ -2899,17 +2899,24 @@ wait untill text in selector disabppears end if data[:organization] - element = instance.find_elements(css: '.modal input.searchableSelect-main')[0] - element.clear - element.send_keys(data[:organization]) begin + target = nil retries ||= 0 - target = nil - until target - sleep 0.5 - target = instance.find_elements(css: ".modal li[title='#{data[:organization]}']")[0] + + 5.times do + element = instance.find_elements(css: '.modal input.searchableSelect-main')[0] + element.clear + element.send_keys(data[:organization]) + + 10.times do + sleep 0.5 + target = instance.find_elements(css: ".modal li[title='#{data[:organization]}']")[0] + break if target + end + break if target end + raise "Can't find organization #{data[:organization]}" if target.blank? target.click() rescue Selenium::WebDriver::Error::StaleElementReferenceError sleep retries