Selenium¶
perfshop-selenium provides a standalone Chrome Selenium Grid that serves as the WebDriver backend for all E2E test executions in the QA stack (Robot Framework + SeleniumLibrary, pytest + selenium, possibly Cypress or Playwright later).
Source of truth
This page is drawn from the perfshop-selenium block of the compose files.
Image and mode¶
# excerpt — the full block lives in docker-compose.desktop.yml and docker-compose.build.yml
perfshop-selenium:
image: selenium/standalone-chrome:4.43.0
container_name: perfshop-selenium
ports:
- "127.0.0.1:${SELENIUM_HTTP_PORT:-4444}:4444"
- "${SELENIUM_VNC_BIND:-127.0.0.1}:${SELENIUM_VNC_PORT:-7900}:7900"
environment:
SE_NODE_MAX_SESSIONS: 2
SE_VNC_NO_PASSWORD: 1
SE_VNC_VIEW_ONLY: 1
SE_START_XVFB: "true"
CONFIG_FILE: /tmp/config.toml
volumes:
- ./selenium-grid/x11vnc.conf:/home/seluser/.x11vncrc:ro
read_only: true # + seven in-memory areas (tmpfs), non-executable
security_opt: ["no-new-privileges:true"]
cap_drop: ["ALL"]
pids_limit: 2048
mem_limit: 4g
cpus: 2.0
shm_size: 2gb
PerfShop uses the official selenium/standalone-chrome image, pinned to a version (4.43.0, never latest). "Standalone" mode means that hub, node, and browser all run in the same container — no distributed Grid to manage. This is more than enough for PerfShop's pedagogical needs (one or two concurrent tests), and it dramatically simplifies deployment.
The service ships locked down, its API closed and its desktop view-only: see Security below.
Critical environment variables¶
| Variable | Value | Effect |
|---|---|---|
SE_NODE_MAX_SESSIONS=2 |
— | Maximum 2 concurrent WebDriver sessions per node. Lets a student launch a test through Scripts UI while a Squash TM campaign runs in parallel. |
SE_VNC_NO_PASSWORD=1 |
— | No password on the noVNC desktop: a student opens http://HOST_IP:7900 and watches, with nothing to type. This is only safe because the desktop is view-only (next row). Without this variable, the image would fall back to its factory password, "secret", which is public. |
SE_VNC_VIEW_ONLY=1 |
— | View-only desktop: you see the browser, you can neither click, type nor paste. The selenium-grid/x11vnc.conf file, mounted read-only, enforces the same in x11vnc (and cuts clipboard exchange) even if this variable went missing. |
CONFIG_FILE=/tmp/config.toml |
— | The grid writes its configuration at startup; since the container file system is read-only, it writes it to an in-memory area. |
SE_START_XVFB=true |
— | Forces the start of a virtual X server (Xvfb). Required for Chrome to run in headless-compatible mode in the container while remaining capturable through VNC. |
shm_size: 2gb — shared memory¶
This Docker option allocates 2 GB of shared memory (/dev/shm) to the Selenium container. It is a hard constraint of Chrome: without this allocation, Chrome crashes unpredictably when opening tabs or running complex JavaScript, with errors such as DevToolsActivePort file doesn't exist or silent segfaults.
The official Selenium image documents this requirement. PerfShop applies it systematically.
Two exposed ports¶
flowchart LR
TR["perfshop-test-runner<br/>(Robot Framework / pytest)"]
subgraph SEL["perfshop-selenium"]
direction TB
WD["WebDriver endpoint<br/>:4444/wd/hub"]
VNC["noVNC server<br/>:7900"]
CHROME["Google Chrome<br/>(headless / Xvfb)"]
WD --> CHROME
VNC --> CHROME
end
USER["Instructor<br/>or student"]
TR -->|"POST /wd/hub/session<br/>GET /wd/hub/status"| WD
USER -->|"http://HOST_IP:7900<br/>(noVNC web client)"| VNC
Port 4444 — WebDriver¶
This is the standard Selenium port. All WebDriver clients (Java, Python, JavaScript, Robot Framework) talk to this endpoint over HTTP. The full hub URL is http://perfshop-selenium:4444/wd/hub (on internal DNS) or http://localhost:4444/wd/hub (from the host).
This URL is passed to the test runner through the SELENIUM_REMOTE_URL environment variable (see test-runner.md).
The WebDriver API has no authentication
Whoever reaches port 4444 drives the browser and can have commands executed in the container. It is therefore published on the machine only (127.0.0.1), with no variable to open it. Tests do not need it: they go through the Docker network (perfshop-selenium:4444). Never expose it, neither on a classroom network nor behind a reverse proxy.
Port 7900 — noVNC¶
Port 7900 is a major pedagogical feature. It exposes a noVNC client (VNC over WebSocket in the browser): open a http://HOST_IP:7900 tab — the address of the machine that runs the stack, the one the welcome page gives — and watch live the Chrome session running the test. The desktop is view-only — you watch, you do not drive. The example file opens it to the network: students watch it from their own machine.
sequenceDiagram
autonumber
actor S as Student
participant NAV as Browser<br/>(tab 1)
participant SEL as perfshop-selenium<br/>:7900 noVNC
participant CHROME as Chrome inside the container<br/>(Xvfb)
participant TR as perfshop-test-runner
S->>NAV: Opens http://HOST_IP:7900
NAV->>SEL: noVNC WebSocket
SEL->>CHROME: Captures framebuffer
CHROME-->>SEL: Pixels
SEL-->>NAV: Video stream over WebSocket
NAV-->>S: Displays Chrome live
Note over S,TR: Meanwhile, a test runs
TR->>SEL: POST /wd/hub/session (launch Chrome)
SEL->>CHROME: Navigates, clicks, fills forms
Note over NAV,CHROME: Student sees everything in real time<br/>in the noVNC tab
Concretely, while a Robot Framework test runs from the test runner, the student can open noVNC on a second screen and watch Chrome navigate, click, and fill forms — exactly as if they were screen-sharing a virtual machine.
This is especially useful for:
- Debugging a failing test: seeing where Chrome stops, which element is not found
- Demoing a scenario: the instructor launches a test, students watch it unfold live
- Understanding WebDriver: visualizing concretely that a test drives a real browser
A desktop you watch, without a password¶
With SE_VNC_NO_PASSWORD=1, the noVNC client opens directly on the Chrome session, with no password prompt: a student discovering the tool clicks Connect and watches. With SE_VNC_VIEW_ONLY=1, watching is all they can do: a visitor's mouse, keyboard and clipboard never reach the browser.
Alternative ports depending on the environment
The SELENIUM_HTTP_PORT (default 4444) and SELENIUM_VNC_PORT (default 7900) variables allow host ports to be remapped in case of conflict. The internal ports (4444 and 7900) are fixed — they are defined by the official Selenium image.
Security: API closed, desktop view-only¶
Up to the previous version, the desktop was published on every interface, without a password and controllable. On an installation published on the Internet, on 2026-08-06, a stranger opened it, typed a command, became root through sudo and installed a cryptocurrency miner that stayed for two months. The service now ships as follows:
| Protection | How | What it prevents |
|---|---|---|
| API on the machine only | 127.0.0.1 for port 4444, always, with no variable |
a machine on the network, or the Internet, driving the browser |
| Desktop: chosen listening address | SELENIUM_VNC_BIND — 0.0.0.0 in the example file (students watch it from their own machine), 127.0.0.1 when the key is missing or on an Internet-facing machine |
a published installation showing the desktop without having decided to |
| View-only desktop | SE_VNC_VIEW_ONLY=1 and selenium-grid/x11vnc.conf (viewonly, clipboard cut) |
a visitor clicking, typing or pasting |
sudo disabled |
security_opt: no-new-privileges:true, cap_drop: ALL |
becoming root in the container |
| Read-only file system | read_only: true, seven noexec in-memory areas |
altering the container scripts, dropping a program in it, surviving a restart |
| seluser's areas owned by seluser | uid=1200,gid=1201 on the five areas of seluser and supervisord (/tmp and /var/tmp stay owned by root) |
an older Docker (24, as on a Synology NAS) leaving them to root: the desktop would not start |
| Limits | pids_limit, mem_limit, cpus |
a rogue program taking over the machine |
| Pinned image | selenium/standalone-chrome:4.43.0 |
an untested update arriving on its own |
In a classroom — the ordinary case: the instructor installs the stack, students open the desktop from their own machine, through the address of the instructor's (HOST_IP). There is nothing to do: ./build.sh desktop and ./build.sh unix install the example file, which opens the desktop to the network, still view-only, and the installer says so in both of its summaries. The API does not open.
On an Internet-facing machine (rented server, public demonstration): set SELENIUM_VNC_BIND=127.0.0.1 in .env.example before installing — or in the .env of an installed stack, then recreate the service and the welcome page, whose link follows the same variable (docker compose up -d --no-deps --force-recreate perfshop-selenium perfshop-welcome). Without a password, an open desktop can be watched from anywhere.
The link to the desktop follows its listening address. Open to the network (example file), the welcome page and the installer summary give the host address (HOST_IP). Kept on the machine only, they give http://localhost:7900: it then opens only from the machine that runs the stack. Bound to another address of the machine, that address.
Behind a reverse proxy (public demonstration): set SELENIUM_VNC_BIND=127.0.0.1 and point the proxy to http://localhost:7900; publish no rule towards port 4444. Any visitor will see what the tests display: do not scroll real data through it.
Check (no write; the probe shows up without a password, moves the mouse and verifies that the pointer did not move):
node tools/securite/selenium-durci.mjs --compose
node tools/securite/selenium-durci.mjs --conteneur perfshop-selenium --bureau-ouvert --sonde ws://127.0.0.1:7900/websockify
--bureau-ouvert accepts a desktop published on the network, the case of an installed stack; drop it if you kept the desktop on the machine only: the tool then requires 127.0.0.1. tools/tps/etat-pile.sh runs these checks on every pass, and node --test "tools/securite/test/*.test.mjs" rejects any step back in the compose files.
What these protections do not cover
They prevent anyone from driving the desktop and lock this container down. They do not make the rest of the stack safe to publish as is: see Hardening an exposed installation.
No declared dependency¶
Selenium has no depends_on in the compose file: it starts in parallel with the other services. This is consistent — the test runner will send it a WebDriver request only when a test starts, and if Selenium is not yet ready at that moment, the test runner will retry or fail cleanly.
In practice, Selenium starts in 10 to 20 seconds (Chrome download, Xvfb startup, hub launch). This is faster than Squash TM which has a start_period: 120s, so Selenium is always ready before the first execution.
Typical use case — Robot Framework¶
Here is what using Selenium looks like from a Robot Framework test running in the test runner:
*** Settings ***
Library SeleniumLibrary
*** Variables ***
${SELENIUM_URL} %{SELENIUM_REMOTE_URL}
${FRONTEND_URL} %{PERFSHOP_FRONTEND_INTERNAL}
*** Test Cases ***
Student Login
Open Browser ${FRONTEND_URL}/login chrome
... remote_url=${SELENIUM_URL}
... options=add_argument("--no-sandbox"); add_argument("--disable-dev-shm-usage")
Input Text id=email demo@perfshop.io
Input Password id=password demo
Click Button Sign in
Wait Until Page Contains My account
Close Browser
Key points:
${SELENIUM_URL}is read from theSELENIUM_REMOTE_URL=http://perfshop-selenium:4444/wd/hubenvironment variable passed to the test runner by compose.--no-sandboxand--disable-dev-shm-usageare the classic Chrome flags for running inside a container (even withshm_size: 2gb, some execution patterns benefit from them).${FRONTEND_URL}points to the frontend using internal Docker DNS (http://perfshop-frontend:80), not tolocalhost. The Chrome container sees the Docker network, not the host network.
Ports¶
| Service | Default host port | Container port | Environment variable |
|---|---|---|---|
perfshop-selenium |
4444 | 4444 | SELENIUM_HTTP_PORT |
perfshop-selenium |
7900 | 7900 | SELENIUM_VNC_PORT |
Going further¶
- Test Runner — main Selenium consumer
- Scripts UI — launches RF tests that use Selenium
- Squash Orchestrator — triggers the same tests over SSH
- QA Stack — Overview — complete workflow