Rodja Trappe 6dba0b4090 Merge pull request #1914 from zauberzeug/refreshable-return há 1 ano atrás
..
README.md a77e3c6121 review há 2 anos atrás
__init__.py 4f500e88d1 began with first selenium pytest há 2 anos atrás
conftest.py 0f1728809f rename index_client to auto_index_client há 1 ano atrás
requirements.txt 724d997513 add bs4 dependency há 2 anos atrás
screen.py 202cb69ad8 remove Server class from public API há 1 ano atrás
test_aggrid.py 31eb0f63f4 convert non-serializable columns in ui.aggrid.from_pandas() (fixes #1698) há 1 ano atrás
test_api_router.py 240ddfa801 adding tests for APIRouter há 2 anos atrás
test_audio.py bf007e09b4 #600 add pytests for replacing custom elements há 2 anos atrás
test_auto_context.py e89b8ba410 fix more pylint issues há 1 ano atrás
test_awaitable_response.py bad0a87563 add documentation for NullResponse há 1 ano atrás
test_binding.py f5dd41d395 refresh binding before page delivery há 1 ano atrás
test_button.py 2ca3f765b7 another code review há 1 ano atrás
test_carousel.py 9c3ea230f5 add pytest há 1 ano atrás
test_chat.py 16465fdc68 chat: translate newlines for non-HTML text only há 2 anos atrás
test_code.py 0d212080e7 add pytest and documentation há 1 ano atrás
test_color_input.py 595955a3ca fix pytests há 1 ano atrás
test_colors.py 8f2adf8253 #600 add unique key prop as a workaround há 2 anos atrás
test_context_menu.py 07a547439c fix click handler for context menu items (fixes #1827) há 1 ano atrás
test_dark_mode.py 90453d7349 #783 add dark_mode pytest há 2 anos atrás
test_date.py afe5023641 add pytest with dynamic props há 2 anos atrás
test_dialog.py 3c00a8619b #338 introduce outbox; update elements during initialization, not when leaving container há 2 anos atrás
test_download.py e89b8ba410 fix more pylint issues há 1 ano atrás
test_echart.py 988b26459f code review há 1 ano atrás
test_editor.py c50d99b8dc try to improve test stability há 1 ano atrás
test_element.py 613925b0e0 use less restrictive rules for XML tag names há 1 ano atrás
test_element_delete.py d9d65d0647 consistently use prefix "on_" for registering handlers only (fixes #1326) há 1 ano atrás
test_endpoint_docs.py e89b8ba410 fix more pylint issues há 1 ano atrás
test_events.py bc5303db02 introduce awaitable response for ui.run_javascript há 1 ano atrás
test_expansion.py 3c00a8619b #338 introduce outbox; update elements during initialization, not when leaving container há 2 anos atrás
test_favicon.py 6645c2029a add missing docstrings to public functions; consistently mark other functions private há 1 ano atrás
test_header.py 6f62d2a777 add pytest for scroll padding há 1 ano atrás
test_helpers.py e89b8ba410 fix more pylint issues há 1 ano atrás
test_highchart.py 1dfb8ea094 update tests and documentation há 1 ano atrás
test_image.py bebc8f9e24 cleanup há 1 ano atrás
test_input.py e89b8ba410 fix more pylint issues há 1 ano atrás
test_interactive_image.py 618b0984e3 add pytest há 1 ano atrás
test_javascript.py bc5303db02 introduce awaitable response for ui.run_javascript há 1 ano atrás
test_joystick.py 2ca3f765b7 another code review há 1 ano atrás
test_json.py e89b8ba410 fix more pylint issues há 1 ano atrás
test_keyboard.py bd0dd2971f fix keyboard test (after removing the invisible element in a previous commit) há 2 anos atrás
test_knob.py aad853b067 #424 add pytest há 2 anos atrás
test_label.py cbd4a53031 #791 add pytest há 2 anos atrás
test_lifecycle.py b44f899d9c fix pytests by setting reconnect_timeout to 0 há 1 ano atrás
test_link.py f2eb6bb10b add pytest for linking to elements há 2 anos atrás
test_log.py baf59020d2 fix another line duplication bug with ui.log há 1 ano atrás
test_markdown.py d06585905a try to fix flaky test há 1 ano atrás
test_menu.py 8cac25a295 move `ui.context_menu` into separate file há 1 ano atrás
test_mermaid.py 873999e08a test dynamic creation of elements with dependencies há 1 ano atrás
test_number.py 11013fbf7b fix pytest há 1 ano atrás
test_observables.py d4f337145d generalize late event registration to other observables há 1 ano atrás
test_open.py a55a452a1c fix some more mypy issues há 1 ano atrás
test_page.py bc5303db02 introduce awaitable response for ui.run_javascript há 1 ano atrás
test_pagination.py f4be80d18f code review há 1 ano atrás
test_plotly.py 3b81379878 remove numpy dependency where possible há 1 ano atrás
test_prod_js.py e696a48e88 rename prod_js parameter há 1 ano atrás
test_query.py 8df7d2546b #1293 fix ui.query with CSS variables há 1 ano atrás
test_radio.py 50bec3a1d3 fix value of ChoiceElements after changing options há 1 ano atrás
test_refreshable.py cf7a0f5cb5 support return values of refreshable function há 1 ano atrás
test_scene.py 0b66e87ecc fix scene tests há 1 ano atrás
test_select.py 919b606102 code review há 1 ano atrás
test_serving_files.py 320731bf36 try to fix pytest há 1 ano atrás
test_spinner.py 1355cc1465 #368 introduce ui.spinner há 2 anos atrás
test_splitter.py b03f70e027 #676 review, additional splitter example há 2 anos atrás
test_stepper.py 72b6976a6b add pytest há 1 ano atrás
test_storage.py df5665426f fix pytests há 1 ano atrás
test_table.py d44a3d0ace use properties to avoid overwriting references há 1 ano atrás
test_tabs.py 95de7d8330 code review há 1 ano atrás
test_tailwind.py 97f75b9a54 handle empty tailwind values (fixes #1736) há 1 ano atrás
test_time.py 17230d2523 add waits to reduce flakyness há 2 anos atrás
test_timeline.py 756ea00dc8 re-write ui.timeline; add test and documentation há 1 ano atrás
test_timer.py b44f899d9c fix pytests by setting reconnect_timeout to 0 há 1 ano atrás
test_toggle.py d7c7b80a70 add clearable parameter to ui.toggle há 1 ano atrás
test_tree.py 427c38b247 improve stability of tree test há 1 ano atrás
test_upload.py bebc8f9e24 cleanup há 1 ano atrás
test_video.py bf007e09b4 #600 add pytests for replacing custom elements há 2 anos atrás

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 .screen 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.