test_keyboard.py 452 B

12345678910111213141516
  1. from selenium.webdriver.common.by import By
  2. from nicegui import ui
  3. from .screen import Screen
  4. def test_keyboard(screen: Screen):
  5. result = ui.label()
  6. keyboard = ui.keyboard(on_key=lambda e: result.set_text(f'{e.key, e.action}'))
  7. screen.open('/')
  8. assert screen.selenium.find_element(By.ID, keyboard.id)
  9. screen.wait(1.0)
  10. screen.type('t')
  11. screen.should_contain('t, KeyboardAction(keydown=False, keyup=True, repeat=False)')