I did what you need, but I separated the application from my container.
You can try it yourself with my example here: https://github.com/xbx/webdriverio-docker-example
Here are the changes:
First add catch() to your webdriverio instance:
webdriverio .remote(options) .init() .url('http://app:3000') .getTitle().then(function(title) { console.log('Title was: ' + title) }) .catch(function(e){ console.log('Error!') console.log(e) }) .end()
Secondly, use chrome as your browser name (it must be due to the use of selenium chrome):
desiredCapabilities: { browserName: 'chrome' }
Thirdly, correctly indicate your application:
.url('http://app:3000')
See how the containers are arranged:
version: "3" services: selenium: image: selenium/standalone-chrome ports: - 4444:4444 links: - app app: build: . ports: - 3000:3000 testing: build: context: . dockerfile: Dockerfile.testing command: /wait-for-it.sh selenium:4444 -- /wait-for-it.sh app:3000 -- node /e2e.js links: - app - selenium volumes: - ./wait-for-it.sh:/wait-for-it.sh
Launch: docker-compose up --build
Attaching to question_app_1, question_selenium_1, question_testing_1 app_1 | Started app. selenium_1 | 12:19:45.516 INFO - Selenium build info: version: '3.4.0', revision: 'unknown' ... selenium_1 | 12:19:45.769 INFO - Selenium Server is up and running testing_1 | Starting testing. selenium_1 | 12:19:47.827 INFO - Executing: [get: http://app:3000]) app_1 | Hit! selenium_1 | 12:19:48.210 INFO - Done: [get: http://app:3000] selenium_1 | 12:19:48.220 INFO - Executing: [get title]) selenium_1 | 12:19:48.239 INFO - Done: [get title] testing_1 | Title was: Hi, this is the title
Edit: simple change for docker version 1:
testing: build:. dockerfile: Dockerfile.testing ...... ......
source share