Acceptance tests using a web browser and Selenium - automated software that simulates user actions performed on a website.
Please read this document before you start writing or modifying any tests.
make ENV_FILE=$ENV SUITE=$SUITE test_gui
Commands for exact tests suites can be found in bamboo-specs/gui.
For more information about running tests using make, see
Running acceptance tests section in the main README.
Example: QoS basic tests on automatic Onedata deployment using a dockerized testing toolkit
make ENV_FILE=1oz_2op_deployed SUITE=test_qos_basic OPTS="--no-clean --no-pull" test_gui
Note: Onedata deployment does not have to be started in order to run
tests using make (it will start automatically).
Known issue: flag --local won't work, because make by default is using
--xvfb flag, and they need to be mutually exclusive.
The test_run.py command is essentially invoked by Makefile, but using it directly allows better parameterization and overcoming of some known issues.
Note: all examples use the --no-clean option, make sure to remove it if you
require a fresh deployment every run.
./test_run.py -t tests/gui -i onedata/acceptance_gui:latest --test-type gui \
--driver=Chrome --xvfb --no-clean
The Onedata deployment will be set up automatically with a Onezone and Oneprovider
(for details see environments dir with configurations). Setting up the deployment
can take some time.
We recommend using onedata/acceptance_gui:latest testing docker image
when working on branches based on the develop branch. To run older versions,
use the image defined as default in Makefile.
For some tests you should specify --env-file - see
bamboo-specs/gui.
Otherwise, the default one will be used.
Example that starts a deployment using 1oz_1op_not_deployed_2_nodes.yaml
and then runs tests on it:
./test_run.py -t tests/gui/scenarios/test_onepanel_deployment_with_2_hosts.py \
-i onedata/acceptance_gui:latest --test-type gui --driver=Chrome --xvfb \
--env-file=1oz_1op_not_deployed_2_nodes --no-clean
Acceptance tests using Selenium (GUI, Mixed) can be run with --local flag to
use the locally installed testing toolkit.
Running test this way greatly helps with debug because you can observe the test happening "live" in your browser.
-
Python 3.12: we recommend using Python 3.12. Python 3.8 and newer are also supported.
-
required Python packages: tests/gui/requirements.txt. To install Python dependencies run (invoke from repo root):
pip3 install -r tests/gui/requirements.txtOn Ubuntu 22.04 this won't work on default Python 3.10, a version 3.8 must be installed on the side.
-
Google Chrome: currently, only Google Chrome is used and well tested. You can use other browsers on your own risk.
-
xclip
-
chromedriver: you can install the Google Chrome
chromedriverin suitable version for it from: https://chromedriver.chromium.org/downloads.Note:
chromedriverhave to be located in $PATH and namedchromedriver.
There is a problem with automatic Onedata deployment setup for tests which
are using local machine. With --local flag, pytest is run differently than
on docker (have different options). Until this is fixed, a Onedata deployment
has to be ready in order to run tests locally.
The manual start of Onedata deployment is described in the following document: one-env guide.
Note: the one-env environment that is set up should be accessible via hostnames
(eg. https://dev-onezone.default.svc.cluster.local). Make sure that you can open address
of Onezone in your browser before starting tests.
Command ./onenv hosts (invoke from repo one-env root) add entries
in /etc/hosts. For more information see Starting Onedata deployment section in
one-env.
The --local flag indicates that the tests should be started using locally
installed testing toolkit.
./test_run.py -t tests/gui --test-type gui --driver=Chrome --local --no-cleanTo run a single test case:
./test_run.py -t tests/gui/scenarios/test_onezone_basic.py --test-type gui -vvv \
--timeout 5 --reruns 0 --reruns-delay 0 --local --no-clean --driver=Chrome \
-k test_onezone_login_page_renders_with_proper_titleNote: the --update-etc-hosts flag will add entries in /etc/hosts when the
deployment is ready.
The test report in HTML format with embedded screenshots of browser in failed test will be saved to:
<onedata_repo_root>/tests/gui/logs/report.<time_stamp>/report.html
For some purposes, taking screenshots can be required at the time of test run.
In steps of scenarios simply use:
driver.get_screenshot_as_file('/tmp/some-screenshot.png')where driver is instance of Selenium WebDriver
-
The default configuration of
pytest-selenium-multifor sensitive URLs is inverted: all tests are considered non-destructive by default. You can add a@pytest.mark.destructivemark to test scenario to mark test as destructive. -
The
sensitive_urlfixture has module scope, because we start new environment for each module (so it could have differentbase_url's)