在运行ng e2e时,我得到以下内容
✓ should display message saying sign up
✗ should be able to sign up with a valid user
- Failed: unknown error: an X display is required for keycode conversions, consider using Xvfb
(Session info: headless chrome=59.0.3071.71)
(Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 3.13.0-48-generic x86_64)
(Session info: headless chrome=59.0.3071.71)
(Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 3.13.0-48-generic x86_64)
配置:
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
'args': ['show-fps-counter=true', '--no-sandbox', '--headless', '--disable-gpu']
}
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
beforeLaunch: function() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
},
onPrepare() {
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
现在从这里开始配置: Using Headless Chrome.
答案 0 :(得分:0)
上述问题归因于sendkeys。 截至目前,没有无头浏览器和sendkeys的解决方案,请参阅Issue。
现在适用于xvfb。
答案 1 :(得分:0)
作为mentioned in this bug report,davidthornton编译了chromedriver-2.31的二进制文件,其中包含修复:https://github.com/davidthornton/chromedriver-2.31
我已成功使用此功能,将此oneliner添加到我的ci安装脚本中:
mkdir -p ~/chromedriver && wget https://github.com/davidthornton/chromedriver-2.31/blob/master/chromedriver\?raw\=true -O ~/chromedriver/chromedriver && chmod a+x ~/chromedriver/chromedriver && export PATH="$HOME/chromedriver:$PATH"
让我们希望他们很快就能发布chromedriver 2.31。
点击此处查看发布:https://sites.google.com/a/chromium.org/chromedriver/downloads