使用CLI在Angular 8.0.2中为应用程序生成了默认设置(减去路由)。
ng test
有效,但ng e2e
无效。该错误抱怨Chrome。
C:\Users\user\my-dream-app>ng e2e
[06:26:10] I/update - chromedriver: file exists C:\Users\user\my-dream-app\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_75.0.3770.8.zip
[06:26:10] I/update - chromedriver: unzipping chromedriver_75.0.3770.8.zip
[06:26:10] I/update - chromedriver: chromedriver_75.0.3770.8.exe up to date
Date: 2019-06-10T10:26:29.077Z
Hash: d3f131a7889575adf622
Time: 13878ms
chunk {main} main.js, main.js.map (main) 9.77 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 248 kB [initial] [rendered]
chunk {polyfills-es5} polyfills-es5.js, polyfills-es5.js.map (polyfills-es5) 380 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 16.3 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.67 MB [initial] [rendered]
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
i ?wdm?: Compiled successfully.
[06:26:30] I/launcher - Running 1 instances of WebDriver
[06:26:30] I/direct - Using ChromeDriver directly...
DevTools listening on ws://127.0.0.1:16131/devtools/browser/84b893db-c880-496e-a908-248c8a756f0a
[06:26:33] E/launcher - session not created: This version of ChromeDriver only supports Chrome version 75
(Driver info: chromedriver=75.0.3770.8 (681f24ea911fe754973dda2fdc6d2a2e159dd300-refs/branch-heads/3770@{#40}),platform=Windows NT 6.1.7601 SP1 x86_64)
[06:26:33] E/launcher - SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version 75
(Driver info: chromedriver=75.0.3770.8 (681f24ea911fe754973dda2fdc6d2a2e159dd300-refs/branch-heads/3770@{#40}),platform=Windows NT 6.1.7601 SP1 x86_64)
at Object.checkLegacyResponse (C:\Users\user\my-dream-app\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Users\user\my-dream-app\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\user\my-dream-app\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
From: Task: WebDriver.createSession()
at Function.createSession (C:\Users\user\my-dream-app\node_modules\selenium-webdriver\lib\webdriver.js:769:24)
at Function.createSession (C:\Users\user\my-dream-app\node_modules\selenium-webdriver\chrome.js:761:15)
at Direct.getNewDriver (C:\Users\user\my-dream-app\node_modules\protractor\built\driverProviders\direct.js:77:33)
at Runner.createBrowser (C:\Users\user\my-dream-app\node_modules\protractor\built\runner.js:195:43)
at q.then.then (C:\Users\user\my-dream-app\node_modules\protractor\built\runner.js:339:29)
at _fulfilled (C:\Users\user\my-dream-app\node_modules\q\q.js:834:54)
at C:\Users\user\my-dream-app\node_modules\q\q.js:863:30
at Promise.promise.promiseDispatch (C:\Users\user\my-dream-app\node_modules\q\q.js:796:13)
at C:\Users\user\my-dream-app\node_modules\q\q.js:556:49
at runSingle (C:\Users\user\my-dream-app\node_modules\q\q.js:137:13)
[06:26:33] E/launcher - Process exited with error code 199
我承认我仍在学习Angular,但经过一番谷歌搜索后,我认为这个问题是resolved,所以为什么会发生这种情况以及如何解决呢?我的Chrome浏览器版本(显示为大约chrome)是Chrome版本74.0.3729.169
答案 0 :(得分:1)
手动将Chrome更新到最新版本,然后重新启动Chrome。现在e2e测试工作了。
答案 1 :(得分:1)
Chromedriver需要在本地安装特定版本的chrome,因此请确保您在本地安装的Chrome与驱动程序使用的版本相同。
出于某些原因,Chrome有时无法自动升级,但是如果您转到关于Google Chrome浏览器的帮助->,则可以看到当前版本,然后单击此处的按钮进行升级。