gpt4 book ai didi

linux - E2E测试失败错误: cannot find chrome binary in Linux

转载 作者:太空宇宙 更新时间:2023-11-04 11:51:57 25 4
gpt4 key购买 nike

我正在使用 angular 为 gitlab-ci 管道设置 e2e 测试( Protractor ),实际上我是这个主题的新手。我希望测试是 headless 的,因为 Gitlab-ci 所在的服务器正在 Linux 上运行。

但我总是得到这个错误:

E/launcher - unknown error: cannot find Chrome binary.

对我来说这毫无意义,因为它编译成功并下载、解压缩 Chromedriver 并获得了 1 个正在运行的 Webdriver 实例,但随后它因上述错误而崩溃。

另外我应该提到的是它在本地工作,但是当我推送它时,它没有。

我已经尝试了一些我发现的东西,例如使用“--no-sandbox”编辑 protractor.conf.js,但它对我不起作用。

在这里你可以看到我的 protractor.conf.js

const {SpecReporter} = require('jasmine-spec-reporter');

exports.config = {
allScriptsTimeout: 11000,
specs: [
'./src/**/*.e2e-spec.ts'
],
capabilities: {
browserName: 'chrome', chromeOptions: {
args: [
'--headless',
'--disable-gpu',
'--window-size=800,600',
]
}
},
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.e2e.json')
});
jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: true}}));
}
};

我希望你们能帮助我解决我的问题,非常感谢你们的回答。

最佳答案

如果您的 Chrome 没有安装在标准位置,您可能必须在 protractor.conf.js 中明确指定它:

capabilities: {
'browserName': 'chrome',
"chromeOptions": {
binary: "/Applications/your_path/Google Chrome.app/Contents/MacOS/Google Chrome"
},
},

您可以使用 chromeoptions:

ChromeOptions ChromeOptions = new ChromeOptions();
ChromeOptions.addArguments("--headless", "window-size=1024,768", "--no-sandbox");
driver = new ChromeDriver(ChromeOptions);

关于linux - E2E测试失败错误: cannot find chrome binary in Linux,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55826772/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com