Falko Schindler 59c4451a57 Allow adding SVG layers to `ui.interactive_image` (#4712) 6 روز پیش
..
media 061242c2b2 use local files for testing `ui.interactive_image` (#3118) 11 ماه پیش
README.md 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
__init__.py 4f500e88d1 began with first selenium pytest 2 سال پیش
conftest.py b77d9d95da Integration test framework (#3121) 9 ماه پیش
requirements.txt 3a4d7637dc remove icecream dependency (#3439) 9 ماه پیش
test_add_html.py 3e5f92b23c Make libsass optional (#2809) 1 سال پیش
test_aggrid.py 42d9ef3049 fix typo 6 ماه پیش
test_api_router.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_audio.py 42b3b4c61f add set_source tests for ui.video and ui.audio 1 سال پیش
test_auto_context.py f7c08cfd97 UI context properties (#2905) 1 سال پیش
test_awaitable_response.py bad0a87563 add documentation for NullResponse 1 سال پیش
test_background_tasks.py 2b8b1a6969 Properly await coroutines registered with app.on_shutdown (#4641) 2 هفته پیش
test_binding.py 743c205364 Copyable classes with bindable properties (#4251) 2 ماه پیش
test_button.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_button_dropdown.py 6e61721a3a refactor list and menu items (#2855) 1 سال پیش
test_button_group.py 6e61721a3a refactor list and menu items (#2855) 1 سال پیش
test_card.py c37845689c Fix Quasar's layout rules for `ui.card` that remove children's borders and shadows (#3444) 9 ماه پیش
test_carousel.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_chat.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_chip.py 54c644f393 Add chip element (#2942) 1 سال پیش
test_clipboard.py 5c444ff538 Raise Exception when awaiting JavaScript on auto-index page (#2983) 1 سال پیش
test_code.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_codemirror.py 087a1ed50e fix `ui.codemirror` on JS UTF-16-based indexing (memoize JS length per char + bisect) (#4678) 1 هفته پیش
test_color_input.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_colors.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_context_menu.py 7b4a8d3f6a remove auto-close prop from `ui.context_menu` (fixes #3539) 9 ماه پیش
test_dark_mode.py fca6528270 Fix some failing pytests (#3638) 8 ماه پیش
test_date.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_dialog.py 57fdf434ed add delays to improve test stability 1 ماه پیش
test_download.py 14d0bfd9c5 Introduce more explicit download functions (#4564) 1 ماه پیش
test_echart.py 6e20ce424b Add theme support to ECharts (#4596) 1 ماه پیش
test_editor.py 63deabfd84 Fix value updates in ui.editor after client-side changes (#3346) 9 ماه پیش
test_element.py c3eabbabd3 fix parsing props with URL parameters (fixes #4453) 2 ماه پیش
test_element_delete.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_element_filter.py 26f1d820ac Support radio button in ElementFilter (#3789) 7 ماه پیش
test_endpoint_docs.py e47ec7aec4 Serve codehilite CSS for `ui.markdown` more efficiently (#3792) 7 ماه پیش
test_events.py cd9e5472ad fix events on hidden and disabled elements (#3524) 9 ماه پیش
test_expansion.py d641cdfdac code review 1 سال پیش
test_favicon.py 8c84ad412c fix favicon tests after removing bs4 10 ماه پیش
test_fullscreen.py ce015a49b4 Fullscreen control element (#4165) 3 ماه پیش
test_header.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_helpers.py 4f6114c152 Add HTTPS protocol support to `ui.run` (#4679) 1 هفته پیش
test_highchart.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_html.py 3e65af2827 Introduce an `html` module with plain HTML elements (#3900) 6 ماه پیش
test_image.py acc63e8b3d Show warning when force_reload is used on data sources (#3895) 6 ماه پیش
test_input.py 1786e0a008 Add support for async validation functions (#4024) 5 ماه پیش
test_interactive_image.py 59c4451a57 Allow adding SVG layers to `ui.interactive_image` (#4712) 6 روز پیش
test_javascript.py 5c444ff538 Raise Exception when awaiting JavaScript on auto-index page (#2983) 1 سال پیش
test_joystick.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_json.py da6932894d add pyflakes 1 سال پیش
test_json_editor.py f6e13776ac JSON editor JSONSchema validation (#4012) 5 ماه پیش
test_keyboard.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_knob.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_label.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_leaflet.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_lifecycle.py 5c444ff538 Raise Exception when awaiting JavaScript on auto-index page (#2983) 1 سال پیش
test_link.py 98e00b954b add pycodestyle 1 سال پیش
test_list.py 6e61721a3a refactor list and menu items (#2855) 1 سال پیش
test_log.py 4a67bc95ce New `ui.log` implementation (#2686) 1 سال پیش
test_markdown.py 35eac2444f Use Mermaid API directly to fix nested diagram inside `ui.dialog` inside `ui.markdown` (#4722) 1 هفته پیش
test_menu.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_mermaid.py 2cf863c43b Update JavaScript dependencies (#3654) 8 ماه پیش
test_navigate.py 3e416522fa Implement ui.navigate functionality (#2593) 1 سال پیش
test_notification.py 1e77878609 improve update of notifications (#4379) 2 ماه پیش
test_number.py 3e9da97302 update `ui.number` after sanitization (#3389) 9 ماه پیش
test_observables.py 28253947f5 Implement __copy__ for observable collections (fixes #3023) (#3046) 1 سال پیش
test_outbox.py 8eabbd9c12 add pytest 1 سال پیش
test_page.py 67025a54d7 Multicasting of page-scoped content (#3968) 6 ماه پیش
test_page_title.py 2841869dc8 try to improve robustness of some pytests 1 سال پیش
test_pagination.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_plotly.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_prod_js.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_query.py fca6528270 Fix some failing pytests (#3638) 8 ماه پیش
test_radio.py 1f0bc6dd72 improve radio tests, make them less timing sensitive 7 ماه پیش
test_range.py 5f8a7b9e99 Add range control (#2762) 1 سال پیش
test_rating.py 13b63b24c6 Introduce QRating element (#4347) 2 ماه پیش
test_refreshable.py 57fb4a6ac7 Merge pull request #2268 from zauberzeug/refreshable-method 1 سال پیش
test_restructured_text.py 5d8644743d add pytest 1 سال پیش
test_run.py 0939d863fd fix test_run for Python 3.12.5 9 ماه پیش
test_scene.py c5433b8ff8 Introduce element.html_id property (#4633) 3 هفته پیش
test_scene_view.py 48b6f769b7 Scene view component (#2947) 1 سال پیش
test_select.py 838421bf30 Check value of choice elements against options (#3829) 7 ماه پیش
test_serving_files.py 5e39a4159d Add Cache-Control header to static files (#3865) 7 ماه پیش
test_slide_item.py 49a7fe302e Introduce QSlideItem element (#4358) 2 ماه پیش
test_spinner.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_splitter.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_stepper.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_storage.py 2b8b1a6969 Properly await coroutines registered with app.on_shutdown (#4641) 2 هفته پیش
test_table.py 635a555d44 use `None` for table selection type "none" 3 ماه پیش
test_tabs.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_tailwind.py 392e0d0cf2 Provide public API for accessing `_props`, `_classes` and `_style`. (#3588) 8 ماه پیش
test_teleport.py 6b2df9333d improve teleport test 2 ماه پیش
test_time.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_timeline.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_timer.py b51e70bcb2 Introduce `app.timer` (#4091) 5 ماه پیش
test_toggle.py 8d373eca7f update pytests to import Screen from nicegui.testing 1 سال پیش
test_tree.py 392e0d0cf2 Provide public API for accessing `_props`, `_classes` and `_style`. (#3588) 8 ماه پیش
test_upload.py 2cf863c43b Update JavaScript dependencies (#3654) 8 ماه پیش
test_user_simulation.py e6d4b17195 Add context manager to the user fixture (#4682) 1 هفته پیش
test_video.py 42b3b4c61f add set_source tests for ui.video and ui.audio 1 سال پیش

README.md

Automated Tests for NiceGUI

Motivation

Testing a user interface is hard work. But to ensure NiceGUI is working as expected it is of utmost importance. Even if automated testing needs a lot of infrastructure and results in long execution times, we believe that it's worth the effort when compared to manual testing.

Setup

Please be aware that the below commands install the latest version of the ChromeDriver binary, which is compatible with the version of Google Chrome installed on your system. If you have a different version of Chrome installed, you may need to install a different version of ChromeDriver or update your Chrome installation to be compatible with the installed ChromeDriver version.

Mac

cd nicegui # enter the project root dir
brew install cask chromedriver
python3 -m pip install -r tests/requirements.txt

Note: The above instructions assume that you have already installed Homebrew (a package manager for macOS) on your system. If you haven't, you can follow the instructions on https://brew.sh/ to install it.

Windows

cd nicegui # enter the project root dir
choco install chromedriver
python3 -m pip install -r tests/requirements.txt

Note: The above instructions assume that you have already installed Chocolatey (a package manager for Windows) on your system. If you haven't, you can follow the instructions on https://chocolatey.org/install to install it.

Linux

cd nicegui # enter the project root dir
sudo apt-get update
sudo apt-get install chromium-chromedriver
python3 -m pip install -r tests/requirements.txt

Note: The above instructions assume that you are using a Debian-based Linux distribution. If you are using a different distribution, the package manager and package names may differ. Please refer to the documentation for your distribution for more information.

Usage

Because Selenium queries are quite cumbersome and lengthy, we introduced a Screen class. This provides a high-level interface to work with the currently displayed state of the web browser. The workflow is as follows:

  1. Get the screen fixture by providing screen: Screen as an argument to the function.
  2. Write your NiceGUI code inside the function.
  3. Use screen.open(...) with the appropriate URL path to start querying the website.
  4. For example, use screen.should_contain(...) with some text as parameter to ensure that the text is shown.

Here is a very simple example:

from nicegui import ui
from nicegui.testing import Screen

def test_hello_world(screen: Screen):
    ui.label('Hello, world')

    screen.open('/')
    screen.should_contain('Hello, world')

Have a look at the existing tests for more examples. Internally we use selenium-fixture (see conftest.py). To access the webdriver directly you can use the screen.selenium property. Have a look at https://selenium-python.readthedocs.io/getting-started.html for documentation of the available method calls to the webdriver.