瀏覽代碼

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 selenium.common.exceptions import JavascriptException
 
 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))
 
     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()
     screen.wait(0.1)
     assert position() > pos