-
Notifications
You must be signed in to change notification settings - Fork 14
Selenium Docker: Viewing tests as they run
As a developer I want to observe tests as they run to make sure tested pages are reachable and open completely.
First of all because it is insanely cool :). Secondly it is very useful to see that what you're testing actually works. Considering that Docker container is mostly a "black box", any way to pick inside that box would be super useful.
Luckily docker-selenium offers a debug
version of their Selenium containers: selenium/standalone-chrome-debug
and selenium/standalone-firefox-debug
. Both versions are identical in functionality to non-debug ones with exception that they come bundled with VNC server. With VNC server running inside a Docker container we can see and interact with internal OS and/or browser. With that said, all you need to do is get a VNC viewer such as this one and once tests are started open it up and connect to your localhost. VNC normally runs on port 5900
and we will need to map/expose that port in our docker configuration.
-
wdio-docker-service
will start a Selenium Docker image with debug feature enabled (ex.selenium/standalone-chrome-docker
). - Once service is running (normally on port
4444
), tests will run (inside a container). - Open up your VNC viewer and point it
localhost:5900
to observe tests running. - Once tests are finished wdio will report back results.
This setup resembles regular selenium-docker setup with exception of image used and an addition of VNC port.
Example:
//wdio.conf.js
exports.config = {
host: 'localhost',
path: '/wd/hub', // Required to work with wdio v6
specs: [
'./test/*.js'
],
capabilities: [{
browserName: 'chrome'
}],
sync: true,
logLevel: 'debug',
baseUrl: 'http://webdriver.io',
waitforTimeout: 10000,
connectionRetryTimeout: 90000,
connectionRetryCount: 3,
framework: 'mocha',
mochaOpts: {
ui: 'bdd'
},
services: ['docker'],
dockerLogs: './',
dockerOptions: {
image: 'selenium/standalone-chrome-debug',
healthCheck: 'http://localhost:4444',
options: {
p: ['4444:4444', '5900:5900'],
shmSize: '2g'
}
},
onDockerReady: function() {
//run script to start VNC?
}
};
Important parts here are image
and p
.
-
image
- we use debug version of theselenium-docker-chrome
which isselenium/standalone-chrome-debug
-
p
- we expose additional port5900
to permit VNC client connection