{"id":21379598,"url":"https://github.com/yugokato/selenium-docker-demo","last_synced_at":"2026-05-12T04:33:29.998Z","repository":{"id":108854979,"uuid":"236217396","full_name":"yugokato/selenium-docker-demo","owner":"yugokato","description":"Quick-and-dirty Cross-browser GUI Testing in Python with Selenium and Docker","archived":false,"fork":false,"pushed_at":"2023-05-01T22:23:16.000Z","size":35,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-22T22:31:23.512Z","etag":null,"topics":["cross-browser-testing","docker","parallel-testing","pytest","selenium-webdriver"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yugokato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-25T19:16:53.000Z","updated_at":"2024-09-05T22:18:03.000Z","dependencies_parsed_at":"2024-11-22T10:23:30.369Z","dependency_job_id":"80a9630f-c9bc-4b94-9357-72011842516a","html_url":"https://github.com/yugokato/selenium-docker-demo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugokato%2Fselenium-docker-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugokato%2Fselenium-docker-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugokato%2Fselenium-docker-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yugokato%2Fselenium-docker-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yugokato","download_url":"https://codeload.github.com/yugokato/selenium-docker-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243855729,"owners_count":20358867,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cross-browser-testing","docker","parallel-testing","pytest","selenium-webdriver"],"created_at":"2024-11-22T10:21:33.565Z","updated_at":"2026-05-12T04:33:29.945Z","avatar_url":"https://github.com/yugokato.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Quick-and-dirty Cross-browser GUI Testing in Python with Selenium and Docker\n==============================================================\n\nThis repository was created to demonstrate how on-demand cross-browser GUI testing can be achieved quickly and easily in Python (Pytest) using [docker-selenium](https://github.com/SeleniumHQ/docker-selenium)  images\n\n# How it works\nThe basic idea is simple.  \nYou pass desired browser types as Pytest command line arguments. Then those values will be parametrized.  \nFor each parameter (browser), the following steps will be executed.\n\n1. Create a new browser container on-demand\n2. Run tests\n3. Destroy the browser container  \n\nThe goal is to achieve cross-browser testing quickly and easily, therefore it doesn't require a typical Selenium Grid cluster setup, and it doesn't maintain any resources across tests. It just takes advantage of disposable resources and existing Pytest's capabilities.\n\n\n# Try it out\nClone this repository and `cd` into directory,\n\n```bash\n# Install dependencies\n$ pip install -r requirements.txt\n\n# Build images (chrome/firefox/edge). This will take some time for the first run\n$ ./scripts/build_browser_image.py\n\n# Run tests\n$ pytest -v\n```\n\n##### *System requirements*\n- *nix OS\n- Docker (Tested with version 20.10.13, build a224086)\n- Python \u003e= 3.8 (Tested with 3.8.9 and 3.9.8)\n\n\n# Pytest command options\n```\n$ pytest -h\n\n\u003csnip\u003e\n\ncustom options:\n  --browser={chrome,firefox,edge} [{chrome,firefox,edge} ...]\n                        Browser(s) to test with\n  --headless            Run tests in headless mode\n  --record              Enable video recording during tests. This option will be ignored for headless mode\n  --record-dir=RECORD_DIR\n                        Directory to store recorded video files\n```\n\n\n# Examples of usage\n\n```sh\n# Run tests with all browsers\n$ pytest [PYTEST_OPTIONS]\n\n# Run tests with all browsers in parallel using pytest-xdist\n$ pytest [PYTEST_OPTIONS] -n 3 --dist=loadgroup\n\n# Run tests with a specific browser\n$ pytest [PYTEST_OPTIONS] --browser chrome\n\n# Run tests with specific browsers\n$ pytest [PYTEST_OPTIONS] --browser chrome firefox\n\n# Run tests in headless mode\n$ pytest [PYTEST_OPTIONS] --browser chrome --headless\n\n# Record video\n$ pytest [PYTEST_OPTIONS] --browser chrome --record\n```\n\u003e Unless `--headless` option is explicitly provided, the test session will automatically open your default browser and show the browser container's screen using [noVNC](https://github.com/novnc/noVNC)\n\n\n# Sample results\n\n##### *Sequential testing*\n```bash\n~/Desktop/selenium-docker-demo$ pytest -v tests/test_google.py\n================================== test session starts ===================================\nplatform darwin -- Python 3.9.8, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /Users/yugo/.pyenv/versions/3.9.8/envs/selenium-docker-demo-3.9.8/bin/python3.9\ncachedir: .pytest_cache\nrootdir: /Users/yugo/Desktop/selenium-docker-demo\nplugins: xdist-2.4.0, forked-1.3.0\ncollected 12 items                                                                       \n\ntests/test_google.py::test_google[(chrome:latest)-cat] PASSED                      [  8%]\ntests/test_google.py::test_google[(chrome:latest)-dog] PASSED                      [ 16%]\ntests/test_google.py::test_google[(chrome:latest)-rabbit] PASSED                   [ 25%]\ntests/test_google.py::test_google[(chrome:latest)-bird] PASSED                     [ 33%]\ntests/test_google.py::test_google[(firefox:latest)-cat] PASSED                     [ 41%]\ntests/test_google.py::test_google[(firefox:latest)-dog] PASSED                     [ 50%]\ntests/test_google.py::test_google[(firefox:latest)-rabbit] PASSED                  [ 58%]\ntests/test_google.py::test_google[(firefox:latest)-bird] PASSED                    [ 66%]\ntests/test_google.py::test_google[(edge:latest)-cat] PASSED                        [ 75%]\ntests/test_google.py::test_google[(edge:latest)-dog] PASSED                        [ 83%]\ntests/test_google.py::test_google[(edge:latest)-rabbit] PASSED                     [ 91%]\ntests/test_google.py::test_google[(edge:latest)-bird] PASSED                       [100%]\n\n============================= 12 passed in 189.63s (0:03:09) =============================\n```\n\n##### *Parallel testing*\n```bash\n~/Desktop/selenium-docker-demo$ pytest -v tests/test_google.py --headless -n 3 --dist=loadgroup\n================================== test session starts ===================================\nplatform darwin -- Python 3.9.8, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /Users/yugo/.pyenv/versions/3.9.8/envs/selenium-docker-demo-3.9.8/bin/python3.9\ncachedir: .pytest_cache\nrootdir: /Users/yugo/Desktop/selenium-docker-demo\nplugins: xdist-2.4.0, forked-1.3.0\n[gw0] darwin Python 3.9.8 cwd: /Users/yugo/Desktop/selenium-docker-demo\n[gw1] darwin Python 3.9.8 cwd: /Users/yugo/Desktop/selenium-docker-demo\n[gw2] darwin Python 3.9.8 cwd: /Users/yugo/Desktop/selenium-docker-demo\n[gw0] Python 3.9.8 (main, Nov 11 2021, 19:58:26)  -- [Clang 12.0.0 (clang-1200.0.32.29)]\n[gw1] Python 3.9.8 (main, Nov 11 2021, 19:58:26)  -- [Clang 12.0.0 (clang-1200.0.32.29)]\n[gw2] Python 3.9.8 (main, Nov 11 2021, 19:58:26)  -- [Clang 12.0.0 (clang-1200.0.32.29)]\ngw0 [12] / gw1 [12] / gw2 [12]\nscheduling tests via LoadBrowserScheduling\n\ntests/test_google.py::test_google[(edge:latest)-cat] \ntests/test_google.py::test_google[(chrome:latest)-cat] \ntests/test_google.py::test_google[(firefox:latest)-cat] \n[gw0] [  8%] PASSED tests/test_google.py::test_google[(chrome:latest)-cat] \ntests/test_google.py::test_google[(chrome:latest)-dog] \n[gw2] [ 16%] PASSED tests/test_google.py::test_google[(edge:latest)-cat] \ntests/test_google.py::test_google[(edge:latest)-dog] \n[gw1] [ 25%] PASSED tests/test_google.py::test_google[(firefox:latest)-cat] \ntests/test_google.py::test_google[(firefox:latest)-dog] \n[gw0] [ 33%] PASSED tests/test_google.py::test_google[(chrome:latest)-dog] \ntests/test_google.py::test_google[(chrome:latest)-rabbit] \n[gw2] [ 41%] PASSED tests/test_google.py::test_google[(edge:latest)-dog] \ntests/test_google.py::test_google[(edge:latest)-rabbit] \n[gw1] [ 50%] PASSED tests/test_google.py::test_google[(firefox:latest)-dog] \ntests/test_google.py::test_google[(firefox:latest)-rabbit] \n[gw0] [ 58%] PASSED tests/test_google.py::test_google[(chrome:latest)-rabbit] \ntests/test_google.py::test_google[(chrome:latest)-bird] \n[gw2] [ 66%] PASSED tests/test_google.py::test_google[(edge:latest)-rabbit] \ntests/test_google.py::test_google[(edge:latest)-bird] \n[gw1] [ 75%] PASSED tests/test_google.py::test_google[(firefox:latest)-rabbit] \ntests/test_google.py::test_google[(firefox:latest)-bird] \n[gw0] [ 83%] PASSED tests/test_google.py::test_google[(chrome:latest)-bird] \n[gw2] [ 91%] PASSED tests/test_google.py::test_google[(edge:latest)-bird] \n[gw1] [100%] PASSED tests/test_google.py::test_google[(firefox:latest)-bird] \n\n============================= 12 passed in 74.31s (0:01:14) ==============================\n```\n\nIn this scenario 3 containers will run at the same time\n```sh\n~/Desktop/selenium-docker-demo$ docker ps\nCONTAINER ID   IMAGE                     COMMAND                  CREATED          STATUS          PORTS                                                                                            NAMES\n0fd80386b873   selenium-firefox:latest   \"/opt/bin/entry_poin…\"   41 seconds ago   Up 34 seconds   5900/tcp, 0.0.0.0:4445-\u003e4444/tcp, :::4445-\u003e4444/tcp, 0.0.0.0:7901-\u003e7900/tcp, :::7901-\u003e7900/tcp   goofy_turing\nf5eb3340bad4   selenium-chrome:latest    \"/opt/bin/entry_poin…\"   41 seconds ago   Up 35 seconds   0.0.0.0:4444-\u003e4444/tcp, :::4444-\u003e4444/tcp, 0.0.0.0:7900-\u003e7900/tcp, :::7900-\u003e7900/tcp, 5900/tcp   romantic_thompson\nc50270a802b1   selenium-edge:latest      \"/opt/bin/entry_poin…\"   41 seconds ago   Up 36 seconds   5900/tcp, 0.0.0.0:4446-\u003e4444/tcp, :::4446-\u003e4444/tcp, 0.0.0.0:7902-\u003e7900/tcp, :::7902-\u003e7900/tcp   vibrant_swartz\n```\n\n# Write your own script\nThe `driver` fixture (an instance of Selenium RemoteWebDriver) is available in your test functions. It is implicitly \nparametrized based on browser types you passed as Pytest command line arguments, or \nChrome/Firefox/Edge by default. A corresponding browser container should be up and running by the time \na test function is executed.  \nEither use the `driver` as it is or define a custom fixture that wraps the `driver` with your own GUI automation framework.\n\nconftest.py\n```python\nimport pytest\n\n# Import your Selenium automation framework\nfrom selenium_automation.framework import App   # noqa\n\n@pytest.fixture\ndef app(driver):\n    \"\"\"My application\"\"\"\n    myapp = App(driver)\n    myapp.login()\n    yield myapp\n    myapp.logout()\n```\n\ntest.py\n```python\ndef test_do_something(app):\n    result = app.do_something()\n    assert result\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugokato%2Fselenium-docker-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyugokato%2Fselenium-docker-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyugokato%2Fselenium-docker-demo/lists"}