Skip to content

Selenium testing in CI #30

@rouilj

Description

@rouilj

The Roundup has a medium sized test suite. This includes running against a live server (see test/test_liveserver.py). It would be good to get the tests @BharathKanama is working on into
the Roundup suite. We have CI (continuous integration) testing via GitHub actions.

Since the selenium tests could run in CI or on a desktop, run headless chrome if the DISPLAY
environment variable is not defined. If DISPLAY is set (even if it is empty), run the browser in
"headfull"?? mode. The latter is to be used when running on the desktop.

If the tests won't pass in headless mode for some reason, one of the references shows how to start Xfb
as a dummy X server for chrome to use in CI. But running headless would be better.

If there is a way to run in headfull mode in CI and capture the results of the run, that would be
interesting info to link to. Implementing is out of scope for this ticket.

It looks like the github action workflow in .github/workflows/ci-test will need to be changed to
load chrome (and maybe chrome-driver) using apt and 'selenium' using pip. According to
https://selenium-python.readthedocs.io/installation.html newer versions should include
https://www.selenium.dev/documentation/selenium_manager/ which is supposed to handle
installation of the chrome or other browser driver. From today's standup discusion I have
the impression it's not working and the driver has to be explicitly installed??

The selenium tests should be guarded using an @skip_selenium decorator. See how
skip_requests or skip_brotli are set up in test_liveserver. This will allow the testsuite to run
in an environment where selenium is not loaded.

Create a class TestSelenium that inherits from WsgiSetup that is decorated with @skip_selenium.

References:

https://dev.to/delrayo/executing-selenium-test-with-pythonpytest-using-github-actions-317c

The first answer at:
https://stackoverflow.com/questions/62364711/how-can-i-get-selenium-tests-to-run-in-python-with-github-actions looks at how selenium sets up their tests.

https://docs.dev-tools.ai/blog/running-ui-tests-in-github-actions

https://dev.to/pratyushsingh07/integrating-github-actions-with-selenium-cp0 (note I am not a fan of snaps which this answer uses to install chrome)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions