无法在 angular 项目中启动端到端测试
Unable to start e2e tesing in angular project
运行 我的 angular 项目的 e2e 测试抛出。
我的 chrome 版本:版本 87.0.4280.141(正式版)(x86_64)
我在 chrome 浏览器中启用了自动更新。好像是浏览器更新后出现的问题。
ng e2e
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'myhost', ip: 'myip', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '15.0.1'
Driver info: driver.version: unknown
[17:00:29] E/launcher - WebDriverError: Timed out waiting for driver server to start.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'myhost', ip: 'myip', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '15.0.1'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (my-project/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (my-project/node_modules/selenium-webdriver/lib/http.js:509:13)
at my-project/node_modules/selenium-webdriver/lib/http.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:93:5)
From: Task: WebDriver.createSession()
at Function.createSession (my-project/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (my-project/node_modules/selenium-webdriver/chrome.js:761:15)
at createDriver (my-project/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (my-project/node_modules/selenium-webdriver/index.js:626:16)
at Local.getNewDriver (my-project/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
at Runner.createBrowser (my-project/node_modules/protractor/built/runner.js:195:43)
at my-project/node_modules/protractor/built/runner.js:339:29
at _fulfilled (my-project/node_modules/q/q.js:834:54)
at my-project/node_modules/q/q.js:863:30
at Promise.promise.promiseDispatch (my-project/node_modules/q/q.js:796:13)
[17:00:29] E/launcher - Process exited with error code 199
我的量角器配置文件。
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
args: [ "--no-sandbox", "--headless", "--disable-gpu", "--window-size=1600,900" ]
}
},
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
请帮忙。
最后,我通过编辑 node_modules/webdriver-manager/built/lib/files/file_manager.js
解决了这个问题
更新file_manager.js #line-no-166 fileUrl.url = fileUrl.url.replace(/_m1/, '');
Github 问题:https://github.com/angular/webdriver-manager/issues/476
嗯,有道理。我通过手动将 chrome webdriver 的副本放入下载目录而不是使用 webdriver-manager 下载的可执行文件来解决它。
运行 我的 angular 项目的 e2e 测试抛出。
我的 chrome 版本:版本 87.0.4280.141(正式版)(x86_64)
我在 chrome 浏览器中启用了自动更新。好像是浏览器更新后出现的问题。
ng e2e
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'myhost', ip: 'myip', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '15.0.1'
Driver info: driver.version: unknown
[17:00:29] E/launcher - WebDriverError: Timed out waiting for driver server to start.
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'myhost', ip: 'myip', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.6', java.version: '15.0.1'
Driver info: driver.version: unknown
at Object.checkLegacyResponse (my-project/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (my-project/node_modules/selenium-webdriver/lib/http.js:509:13)
at my-project/node_modules/selenium-webdriver/lib/http.js:441:30
at processTicksAndRejections (internal/process/task_queues.js:93:5)
From: Task: WebDriver.createSession()
at Function.createSession (my-project/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
at Function.createSession (my-project/node_modules/selenium-webdriver/chrome.js:761:15)
at createDriver (my-project/node_modules/selenium-webdriver/index.js:170:33)
at Builder.build (my-project/node_modules/selenium-webdriver/index.js:626:16)
at Local.getNewDriver (my-project/node_modules/protractor/built/driverProviders/driverProvider.js:53:33)
at Runner.createBrowser (my-project/node_modules/protractor/built/runner.js:195:43)
at my-project/node_modules/protractor/built/runner.js:339:29
at _fulfilled (my-project/node_modules/q/q.js:834:54)
at my-project/node_modules/q/q.js:863:30
at Promise.promise.promiseDispatch (my-project/node_modules/q/q.js:796:13)
[17:00:29] E/launcher - Process exited with error code 199
我的量角器配置文件。
const { SpecReporter } = require('jasmine-spec-reporter');
exports.config = {
allScriptsTimeout: 11000,
specs: [
'./e2e/**/*.e2e-spec.ts'
],
capabilities: {
'browserName': 'chrome',
'chromeOptions': {
args: [ "--no-sandbox", "--headless", "--disable-gpu", "--window-size=1600,900" ]
}
},
baseUrl: 'http://localhost:4200/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 30000,
print: function() {}
},
onPrepare() {
require('ts-node').register({
project: 'e2e/tsconfig.e2e.json'
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
请帮忙。
最后,我通过编辑 node_modules/webdriver-manager/built/lib/files/file_manager.js
解决了这个问题更新file_manager.js #line-no-166 fileUrl.url = fileUrl.url.replace(/_m1/, '');
Github 问题:https://github.com/angular/webdriver-manager/issues/476
嗯,有道理。我通过手动将 chrome webdriver 的副本放入下载目录而不是使用 webdriver-manager 下载的可执行文件来解决它。