1
0

test_3d_scene.py 734 B

1234567891011121314151617181920212223242526
  1. from nicegui import ui
  2. from selenium.common.exceptions import JavascriptException
  3. from .screen import Screen
  4. def test_moving_sphere_with_timer(screen: Screen):
  5. with ui.scene() as scene:
  6. sphere = scene.sphere()
  7. ui.timer(0.1, lambda: sphere.move(0, 0, sphere.z + 0.01))
  8. screen.open('/')
  9. def position() -> None:
  10. for _ in range(20):
  11. try:
  12. pos = screen.selenium.execute_script('return scene.children[4].position.z')
  13. if pos is not None:
  14. return pos
  15. except JavascriptException:
  16. pass
  17. screen.wait(0.1)
  18. raise Exception('Could not get position')
  19. screen.wait(0.2)
  20. assert position() > 0