test_pages.py 651 B

123456789101112131415161718192021
  1. from nicegui import ui
  2. from selenium.webdriver.common.by import By
  3. async def test_title(server, selenium):
  4. @ui.page('/', title='My Custom Title')
  5. def page():
  6. ui.label('some content')
  7. server.start()
  8. selenium.get(server.base_url)
  9. assert 'My Custom Title' in selenium.title
  10. async def test_route_with_custom_path(server, selenium):
  11. @ui.page('/test_route')
  12. def page():
  13. ui.label('page with custom path')
  14. server.start()
  15. selenium.get(server.base_url + '/test_route')
  16. element = selenium.find_element(By.XPATH, '//*[contains(text(),"custom path")]')
  17. assert element.text == 'page with custom path'