【发布时间】:2021-02-17 11:15:24
【问题描述】:
我正在尝试在 Azure DevOps 管道中运行测试脚本,并且一直在努力让 selenium 运行 Chrome。我总是收到以下错误:
WebDriverError: unknown error: Chrome failed to start: crashed.
(unknown error: DevToolsActivePort file doesn't exist)
我看过很多类似的问题,但没有运气。这只发生在 Azure DevOps 管道上。它适用于我的本地,如果我登录服务器并从构建代理中找到源代码,我可以成功运行“npm run test”。
这是来自 Azure DevOps 的详细错误日志:
下面是运行脚本时触发的 JavaScript 代码:
const { Given, When, Then, AfterAll } = require('@cucumber/cucumber');
const { until, Builder, By, Capabilities } = require('selenium-webdriver');
const { expect } = require('chai');
// WebDriver Setup (for Chrome)
const capabilities = Capabilities.chrome();
const chrome = require('selenium-webdriver/chrome');
const chromeService = chrome.setDefaultService(new chrome.ServiceBuilder('chromedriver.exe').build())
const options = new chrome.Options();
options.addArguments('--headless');
options.addArguments('--no-sandbox');
options.addArguments('--disable-dev-shm-usage');
const driver = new Builder().withCapabilities(capabilities)
.setChromeOptions(options)
.setChromeService(chromeService)
.build();
另外,chrome 驱动和浏览器使用的是同一个版本。
感谢您的帮助。
【问题讨论】:
-
您使用的是自托管代理,您可以尝试使用托管代理并在此处分享结果和ChromeDriver版本吗?
-
您好,刚刚检查一下这个问题现在是否仍然阻碍您?这个问题有更新吗?
-
嗨 Vito,很抱歉回复晚了。是的,我们使用自托管代理,但我会与服务器管理员交谈,看看我们是否可以尝试使用托管代理。感谢您的帮助。
标签: javascript selenium azure-devops