1
我正在一个webdriverIO通过泊坞窗(https://github.com/hulilabs/webdriverio)测试脚本中使用:(?ENV)码头工人组成:如何设置环境变量
docker-compose run --rm webdriverio wdio
现在我需要设置一个变量,此命令这可以在测试文件中使用。
describe('my awesome website', function() {
it('should do some chai assertions', function() {
browser.url(url) // <-- I need to set the variable (dev vs. prod)
browser.getTitle().should.be.equal('Website title')
})
})
我该怎么做?
配置
我wdio.conf.js:
exports.config = {
host: 'hub',
port: 4444,
specs: [
'./specs/**/*.js'
],
capabilities: [
{ browserName: 'chrome' },
{ browserName: 'firefox' }
]
}
我泊坞窗,compose.yml看起来是这样的:
version: '2'
services:
webdriverio:
image: huli/webdriverio:latest
depends_on:
- chrome
- firefox
- hub
environment:
- HUB_PORT_4444_TCP_ADDR=hub
- HUB_PORT_4444_TCP_PORT=4444
volumes:
- /app:/app
hub:
image: selenium/hub
ports:
- 4444:4444
firefox:
image: selenium/node-firefox
ports:
- 5900
environment:
- HUB_PORT_4444_TCP_ADDR=hub
- HUB_PORT_4444_TCP_PORT=4444
depends_on:
- hub
chrome:
image: selenium/node-chrome
ports:
- 5900
environment:
- HUB_PORT_4444_TCP_ADDR=hub
- HUB_PORT_4444_TCP_PORT=4444
depends_on:
- hub
你使用nodeJs吗? –
是的,我愿意。但我认为这与此无关...... – user3142695