test_number.py 812 B

12345678910111213141516171819202122232425262728293031
  1. from selenium.webdriver.common.by import By
  2. from nicegui import ui
  3. from .screen import Screen
  4. def test_apply_format_on_blur(screen: Screen):
  5. ui.number('Number', format='%.4f', value=3.14159)
  6. ui.button('Button')
  7. screen.open('/')
  8. screen.should_contain_input('3.1416')
  9. element = screen.selenium.find_element(By.XPATH, '//*[@aria-label="Number"]')
  10. element.send_keys('789')
  11. screen.click('Button')
  12. screen.should_contain_input('3.1417')
  13. def test_max_value(screen: Screen):
  14. ui.number('Number', min=0, max=10, value=5)
  15. ui.button('Button')
  16. screen.open('/')
  17. screen.should_contain_input('5')
  18. element = screen.selenium.find_element(By.XPATH, '//*[@aria-label="Number"]')
  19. element.send_keys('6')
  20. screen.click('Button')
  21. screen.should_contain_input('10')