test_select.py 822 B

123456789101112131415161718192021222324252627282930313233
  1. from nicegui import ui
  2. from .screen import Screen
  3. def test_select(screen: Screen):
  4. ui.select(['A', 'B', 'C'], value='A')
  5. screen.open('/')
  6. screen.should_contain('A')
  7. screen.should_not_contain('B')
  8. screen.should_not_contain('C')
  9. screen.click('A') # open the dropdown
  10. screen.click('B') # close the dropdown
  11. screen.wait(0.5)
  12. screen.should_not_contain('A')
  13. screen.should_contain('B')
  14. screen.should_not_contain('C')
  15. def test_select_with_input(screen: Screen):
  16. ui.select(['A', 'AB', 'XYZ'], with_input=True)
  17. screen.open('/')
  18. screen.find_by_tag('input').click()
  19. screen.should_contain('XYZ')
  20. screen.find_by_tag('input').send_keys('A')
  21. screen.wait(0.5)
  22. screen.should_contain('A')
  23. screen.should_contain('AB')
  24. screen.should_not_contain('XYZ')