🟨Run Tests in Containers
How to run tests in containers like Docker
Configure the Test Run
Regardless of the scaling option you go with (Selenoid, Zalenium, Docker vs Kubernetes, etc.), you will need to connect your tests to a Remote URL.
You can do this two ways:
Update remote_url in
pylenium.json
Pass in the argument when running the tests in the CLI
Run Tests in CLI
This is the most common option since it is what you will use in your pipelines and CI
Update pylenium.json
You can have multiple pylenium.json
files, so you might have:
dev-pylenium.json
for local developmentci-pylenium.json
for CI Pipelines
Then pick which config file to use in the CLI. For example, in a CI Pipeline:
Config Layers
Layer 1 -
pylenium.json
is deserialized into PyleniumConfigLayer 2 - If there are any CLI args, they will override their respective values in PyleniumConfig
Docker Example
With Docker installed, you can easily spin up a Selenium Grid with the docker-compose
command.
docker-compose.yml
You will need a docker-compose.yml
file and then open a Terminal in the same directory as this file.
This configuration will spin up a Hub node (load balancer), a Chrome node with 2 available drivers and a Firefox node with 4 available drivers.
Spin up the Grid
With a single command you will have all of this created for you:
Once complete, you can visually see this Grid by going to http://localhost:4444/grid/console
Now Configure the Test Run (steps at top of this doc) to target the Hub which will balance the tests across its Nodes.
Scale Nodes
With the YAML file example above, it will create 1 chrome Node with 2 available drivers by default. You can easily scale this to the number you need.
This will spin up the Grid with 5 chrome Nodes!
Tear Down the Grid
When you're done using the Grid, a single command will tear it completely down.
Last updated