首页 > 解决方案 > ChromeDriver 在启动后失败并出现以下错误

问题描述

我正在尝试在 azure devops 的管道中运行量角器 e2e 测试,但它在加载 chrome webdriver 后一直失败。我在本地运行相同的脚本并且工作正常,但在 azure devops 上它失败了。谁能帮我理解它为什么失败?

代理规范:ubuntu-18.04 代理池:Azure Pipelines 节点版本:10.x 使用 Azure Repos

并使用自定义更新根文件夹和 ./node_modules/protractor 中的 webdriver-manger

一旦使用运行 e2e 测试的 npm 完成此操作,但在直接使用 chrome 驱动程序之后它就会失败。

2020-09-01T05:29:18.5579903Z [05:29:18] E/launcher - unknown error: Chrome failed to start: exited abnormally
2020-09-01T05:29:18.5580800Z   (unknown error: DevToolsActivePort file doesn't exist)
2020-09-01T05:29:18.5582329Z   (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
2020-09-01T05:29:18.5591888Z   (Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 5.3.0-1034-azure x86_64)
2020-09-01T05:29:18.5592529Z [05:29:18] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally
2020-09-01T05:29:18.5593004Z   (unknown error: DevToolsActivePort file doesn't exist)
2020-09-01T05:29:18.5593565Z   (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
2020-09-01T05:29:18.5594229Z   (Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 5.3.0-1034-azure x86_64)
2020-09-01T05:29:18.5594817Z     at Object.checkLegacyResponse (/home/vsts/work/1/s/node_modules/selenium-webdriver/lib/error.js:546:15)
2020-09-01T05:29:18.5595359Z     at parseHttpResponse (/home/vsts/work/1/s/node_modules/selenium-webdriver/lib/http.js:509:13)
2020-09-01T05:29:18.5595916Z     at doSend.then.response (/home/vsts/work/1/s/node_modules/selenium-webdriver/lib/http.js:441:30)
2020-09-01T05:29:18.5596243Z     at process._tickCallback (internal/process/next_tick.js:68:7)
2020-09-01T05:29:18.5596481Z From: Task: WebDriver.createSession()
2020-09-01T05:29:18.5597051Z     at Function.createSession (/home/vsts/work/1/s/node_modules/selenium-webdriver/lib/webdriver.js:769:24)
2020-09-01T05:29:18.5597527Z     at Function.createSession (/home/vsts/work/1/s/node_modules/selenium-webdriver/chrome.js:761:15)
2020-09-01T05:29:18.5597853Z     at Direct.getNewDriver (/home/vsts/work/1/s/node_modules/protractor/built/driverProviders/direct.js:77:33)
2020-09-01T05:29:18.5598181Z     at Runner.createBrowser (/home/vsts/work/1/s/node_modules/protractor/built/runner.js:195:43)
2020-09-01T05:29:18.5598472Z     at q.then.then (/home/vsts/work/1/s/node_modules/protractor/built/runner.js:339:29)
2020-09-01T05:29:18.5598732Z     at _fulfilled (/home/vsts/work/1/s/node_modules/q/q.js:834:54)
2020-09-01T05:29:18.5598967Z     at /home/vsts/work/1/s/node_modules/q/q.js:863:30
2020-09-01T05:29:18.5599328Z     at Promise.promise.promiseDispatch (/home/vsts/work/1/s/node_modules/q/q.js:796:13)
2020-09-01T05:29:18.5599570Z     at /home/vsts/work/1/s/node_modules/q/q.js:556:49
2020-09-01T05:29:18.5599801Z     at runSingle (/home/vsts/work/1/s/node_modules/q/q.js:137:13)
2020-09-01T05:29:18.5600161Z [05:29:18] E/launcher - Process exited with error code 199
2020-09-01T05:29:18.6127107Z An unexpected error occurred: undefined
2020-09-01T05:29:18.6680139Z npm ERR! code ELIFECYCLE
2020-09-01T05:29:18.6740337Z npm ERR! errno 1
2020-09-01T05:29:18.6740709Z npm ERR! minterest@1.0.0 e2e: `ng e2e`
2020-09-01T05:29:18.6740974Z npm ERR! Exit status 1
2020-09-01T05:29:18.6741161Z npm ERR! 
2020-09-01T05:29:18.6741404Z npm ERR! Failed at the minterest@1.0.0 e2e script.
2020-09-01T05:29:18.6742262Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-09-01T05:29:18.6770493Z 
2020-09-01T05:29:18.6770952Z npm ERR! A complete log of this run can be found in:
2020-09-01T05:29:18.6772054Z npm ERR!     /home/vsts/.npm/_logs/2020-09-01T05_29_18_670Z-debug.log

我知道那里有很多解决方案,但没有什么对我有用。下面提到了我到目前为止尝试过但一直失败的解决方案

  1. 添加“args”:[“--disable-dev-shm-usage”],“args”:[“--no-sandbox”]。
  2. 尝试并使用终端命令安装 Chrome,以确保它安装在 Rakesh 在此链接中提到的正确路径中。
  3. 尝试将 webdriver-manager 版本降级到 2.38。
  4. 尝试在 firefox 浏览器中运行(在本地运行,但在 azure devops 中运行)。
  5. 尝试将 directConnect 设置为 false 并给出 selenium 地址
  6. 也在隐身模式下运行它
  7. 尝试在本地和 devops 上失败的无头模式下运行
  8. 还尝试运行示例代码,但也不断抛出错误。

我还应该做些什么来解决这个错误?谁能帮忙

标签: typescriptazure-devopsprotractorazure-pipelinese2e-testing

解决方案


推荐阅读