-
Notifications
You must be signed in to change notification settings - Fork 40
Behat
You can connect to the selenium container via VNC to view what is being executed in the browser, which is very helpful for when writing/fixing tests.
To do this, you need to set your behat host to selenium-chrome-debug in your config.php.
If you are using the config.php that comes with docker-dev, simply find $DOCKER_DEV->behat_parallel and set it to false.
Now start the selenium debug container:
tup selenium-chrome-debugYou will then need to re-initialise behat:
cd sitefolder # must run the command from the root of your Totara repo
tzsh php-7.3 # or other php containers, as mentioned above
installbehatNow you can run it:
behat --name="Name of the scenario"In a VNC client, connect using the following credentials to view the scenario running:
| Host | Port | Password |
|---|---|---|
| localhost | 5901 | secret |
If you can't see the scenario executing, it may be because the scenario is missing the @javascript tag.
If the tag isn't specified for the scenario it will run it in headless mode, meaning selenium won't be used.
If you just want to run a suite of behat tests, then it is much faster (and recommended) to run behat in parallel mode (i.e. across multiple threads simultaneously)
To get started, you'll need to start the selenium containers. For the following examples, we are going to run behat across 4 threads. You can adjust this number based on your computers performance.
tup selenium-hub
tscale selenium-chrome 4 # Creates 4 selenium containers for running across 4 threadsLog into one of the PHP containers:
cd sitefolder # must run the command from the root of your Totara repo
tzsh php-7.3 # or other php containers, as mentioned aboveInitiate the behat tests:
# See shell/totara-aliases.sh for what these aliases do
installbehat --parallel=4 # Initiates for 4 threads
# If you are wanting to run a specific tag, then you can optimise behat for it
installbehat --parallel=4 --optimise-runs=@totaraRun behat with:
# See shell/totara-aliases.sh for what these aliases do
# Run all scenarios (takes several hours)
behat
# Run a specific tag
behat --tags=@totara
# Run a specific scenario
behat --name="Name of the scenario"
# Run a specific feature file
behat path/to/feature/fileTo see the status of the selenium containers while they are executing, go to http://localhost:4444/grid/console to view the web console.
Copyright (c) 2025 Totara Learning Solutions Limited