test_3d_scene.py 803 B

12345678910111213141516171819202122232425262728
  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().move(0, -5, 2)
  7. ui.timer(0.03, lambda: sphere.move(sphere.x, sphere.y + 0.05, sphere.z))
  8. screen.open('/')
  9. def position():
  10. for i in range(20):
  11. try:
  12. pos = screen.selenium.execute_script('return scene.children[4].position.y')
  13. ic(pos)
  14. if pos is not None:
  15. return pos
  16. except JavascriptException:
  17. pass
  18. screen.wait(0.1)
  19. raise Exception('Could not get position')
  20. pos = position()
  21. screen.wait(0.2)
  22. assert position() > pos