Node.js 启动chrome headless后无法执行命令

Node.js 启动chrome headless后无法执行命令,node.js,selenium,google-chrome,npm,travis-ci,Node.js,Selenium,Google Chrome,Npm,Travis Ci,我正在使用Travis CI使用selenium测试我的网页。这是我的.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:

我正在使用Travis CI使用selenium测试我的网页。这是我的.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
构建过程正常,但当它到达镀铬无头部件时,它会遇到以下问题:

$ 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

它不会进一步执行“npmtest”命令,因此我的测试不会永远运行。感谢您的回答。

在测试文件中添加headless参数,如下所示:

var-driver=new sw.Builder()
.withCapabilities(sw.Capabilities.chrome())
.setChromeOptions(新的chrome.Options().headless())
.build();

如果删除
--headless
则它工作正常?它显示
命令“google chrome stable--disable gpu--remote debugging port=9222http://localhost:8080“在运行测试时,以1退出。
(节点:6450)未经处理Promisejection警告:WebDriverError:未知错误:Chrome无法启动:异常退出”(未知错误:DevToolsActivePort文件不存在)请帮助@JortegaSo如果“非headless”不起作用,我也不希望headless起作用。是否检查您的Chrome版本是否与您使用的Chrome driver.exe相匹配?是@Jortega两者都是相同的