-
Couldn't load subscription status.
- Fork 14
Selenium Docker: Testing public sites
Simon Tsvilik edited this page Sep 7, 2020
·
5 revisions
As a developer I would like to run functional tests against my public site and use docker-selenium as my testing environment.
Selenium team maintains a repository of Selenium stand-alone servers bundled with either Chrome or Firefox browser and packaged inside a Docker container. More info can be found on their public git page here.
-
wdio-docker-servicewill start a Selenium Docker image of your choice (ex.selenium/standalone-chrome). - Once service is running (normally on port
4444), tests will run (inside a container). - Once tests are finished
wdiowill report back results.
Assuming you have already setup wdio.conf.js, all you need to do is add docker configuration.
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',
healthCheck: 'http://localhost:4444',
options: {
p: ['4444:4444'],
shmSize: '2g'
}
}
};Important parts above are host, services, dockerOptions.
-
host- points to a Selenium running inside a container. -
service- here we specify that we want to usedockerservice (this project). -
dockerOptions- is what makes whole thing work :)-
image- selenium-docker image for Chrome (service will "pull" it from DockerHUB) -
healthCheck- here we specify URL of a Selenium server running inside a Docker container. -
options- these are used to configure how Docker image is going to run-
p- docker command used to map internal port of the service (running inside a container) to an outside port (on localhost). So what that means is that internally Selenium runs on port4444and we want to map it to the same port when accessing outside of the container. -
shmSize- this is a recommended setting for this particular image. It configures shared memory needed to run Chrome browser.
-
-