ソースを参照

pytest: try to fix timing on gh action

Rodja Trappe 2 年 前
コミット
97ba240b58
1 ファイル変更9 行追加2 行削除
  1. 9 2
      tests/test_3d_scene.py

+ 9 - 2
tests/test_3d_scene.py

@@ -1,4 +1,5 @@
 from nicegui import ui
 from nicegui import ui
+from selenium.common.exceptions import JavascriptException
 
 
 from .screen import Screen
 from .screen import Screen
 
 
@@ -9,8 +10,14 @@ def test_moving_sphere_with_timer(screen: Screen):
         ui.timer(0.03, lambda: sphere.move(sphere.x, sphere.y + 0.05, sphere.z))
         ui.timer(0.03, lambda: sphere.move(sphere.x, sphere.y + 0.05, sphere.z))
 
 
     screen.open('/')
     screen.open('/')
-    screen.wait(0.1)
-    def position(): return screen.selenium.execute_script('return scene.children[4].position.y')
+
+    def position():
+        for i in range(5):
+            try:
+                return screen.selenium.execute_script('return scene.children[4].position.y')
+            except JavascriptException:
+                screen.wait(0.1)
+
     pos = position()
     pos = position()
     screen.wait(0.1)
     screen.wait(0.1)
     assert position() > pos
     assert position() > pos