From 2c3e7dac8d238db11162cb1e9d2db2382272d3c4 Mon Sep 17 00:00:00 2001
From: Xiaowu Zhang <xiaowu.zhang@nexedi.com>
Date: Mon, 10 Sep 2018 11:33:36 +0200
Subject: [PATCH] run-zelenium-test: continue to wait except timeout

---
 stack/erp5/template/run-zelenium-test.py.in | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/stack/erp5/template/run-zelenium-test.py.in b/stack/erp5/template/run-zelenium-test.py.in
index a676fa035..f1b1db839 100644
--- a/stack/erp5/template/run-zelenium-test.py.in
+++ b/stack/erp5/template/run-zelenium-test.py.in
@@ -146,9 +146,16 @@ def main():
     ) - 1 # First child is the file name
 
     # Wait for test to be executed
-    WebDriverWait(browser, args.max_duration).until(EC.presence_of_element_located((
-      By.XPATH, '//td[@id="testRuns" and contains(text(), "%i")]' % test_count
-    )))
+    while 1:
+      try:
+        WebDriverWait(browser, args.max_duration).until(EC.presence_of_element_located((
+          By.XPATH, '//td[@id="testRuns" and contains(text(), "%i")]' % test_count
+        )))
+        break
+      except TimeoutException as error:
+        raise error
+      except Exception:
+        traceback.print_exc()
   except:
     test_line_dict['UnexpectedException'] = {
       'test_count': 1,
-- 
2.30.9