我正在使用Travis CI使用硒测试我的网页。这是我的.travis.yml:
sudo: false
language: node_js
node_js:
- node
addons:
chrome: stable
install:
- npm ci
script:
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost:8080
- npm test
构建正常进行,但是当它到达chrome无头部分时,它卡在了这个位置上:
$ google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost:8080
DevTools listening on ws://127.0.0.1:9222/devtools/browser/4d6aeb8f-eb14-4419-96be-40e270c33ccc
它不会进一步执行'npm test'命令,因此我的测试不会永远运行。答案表示赞赏。
像这样在测试文件中添加无头参数:
var driver = new sw.Builder()
.withCapabilities(sw.Capabilities.chrome())
.setChromeOptions(new chrome.Options().headless())
.build();