Falko Schindler 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
..
README.md 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
__init__.py 4f500e88d1 began with first selenium pytest пре 2 година
conftest.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
requirements.txt 724d997513 add bs4 dependency пре 2 година
test_aggrid.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_api_router.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_audio.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_auto_context.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_awaitable_response.py bad0a87563 add documentation for NullResponse пре 1 година
test_binding.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_button.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
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_code.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 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 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_dark_mode.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_date.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_dialog.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_download.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_echart.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_editor.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_element.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_element_delete.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_endpoint_docs.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_events.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_expansion.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_favicon.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_header.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_helpers.py e89b8ba410 fix more pylint issues пре 1 година
test_highchart.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_image.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_input.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_interactive_image.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_javascript.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_joystick.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_json.py e89b8ba410 fix more pylint issues пре 1 година
test_json_editor.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
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 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_link.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_log.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_markdown.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_menu.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_mermaid.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_notification.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_number.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_observables.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_open.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_page.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_page_title.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 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 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_radio.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_refreshable.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_scene.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_select.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_serving_files.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
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 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_table.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_tabs.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_tailwind.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
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 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_toggle.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_tree.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_upload.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 1 година
test_video.py 8d373eca7f update pytests to import Screen from nicegui.testing пре 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.