我使用量角器编写了e2e测试用例。几天前工作正常。但是现在在运行测试用例时。
我正在:
未创建会话:仅此版本的ChromeDriver支持Chrome版本81(驱动程序信息:chromedriver = 81.0.4044.69
我已经安装了81版本的Google Chrome浏览器。然后,我也遇到了同样的错误。我尝试重新安装node_modules,但是没有用。这是我的protractor.conf.json文件的配置:
const { SpecReporter } = require('jasmine-spec-reporter');
const config = require('./protractor.conf').config;
const puppeteer = require('puppeteer');
/**
* @type { import("protractor").Config }
*/
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: [ "--headless", "--no-sandbox" ],
binary: puppeteer.executablePath()
},
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.json')
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
因为您指定了binary: puppeteer.executablePath()
,这意味着量角器将使用npm软件包puppeteer
提供的浏览器,而不是您自己安装的浏览器。
因此问题是'puppeteer'提供的chrome浏览器的版本不是81。要使其变为版本81,或将chromedriver版本更改为与当前的'puppeteer'chrome浏览器兼容。或删除此行binary: puppeteer.executablePath()
以依赖必须手动安装在测试机上的浏览器。