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