selenium - 如何在 Cloud Builders 中成功运行 Protractor e2e 测试?
问题描述
我正在为我们在 Angular 中的项目设置 CI。我们正在使用 Google Cloud Platform 的 Cloud Builder for CI。一切都很顺利,我们可以设置环境,通过 安装包,使用和部署npm
构建项目。angular-cli
但问题是我们在量角器中的测试用例(e2e)不断出错。我们在这里缺少什么?
这是为了使用 Google Cloud Builders 进行持续集成,我们在无头模式下运行量角器,并使用 puppeteer 的 chromium 作为 chrome 的二进制路径
这是我的量角器.conf.js
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts
const { SpecReporter } = require('jasmine-spec-reporter');
const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath()
exports.config = {
allScriptsTimeout: 1000000,
specs: [
'./e2e/*.e2e-spec.ts',
'../e2e/*.e2e-spec.ts'
],
capabilities: {
// browserName: 'chrome',
browserName: 'chrome',
chromeOptions: {
binary: process.env.CHROME_BIN,
args: ['--headless', '--disable-gpu', '--no-sandbox', '--disable-extensions', '--disable-dev-shm-usage', '--disable-setuid-sandbox']
}
},
// seleniumAddress: 'http://127.0.0.1:4444/wd/hub',
// ignoreUncaughtExceptions: true,
directConnect: true,
},
};
这是我们在云构建器中遇到的错误
[11:24:12] E/launcher - unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-1033-gcp x86_64)
[11:24:12] E/launcher - WebDriverError: unknown error: Chrome failed to start: exited abnormally
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location /workspace/node_modules/puppeteer/.local-chromium/linux-662092/chrome-linux/chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
解决方案
推荐阅读
- python - Python Django:在数据库保存()上从服务器向客户端发送消息
- python-3.x - 查看一个值(在列表中)是否在字典中
- c - C 中的 snprintf() 不单独处理目标字符串的最低两个字节
- .net-core - 在哪里可以找到 IPluralizer?
- python - 对复合 sqlalchemy 查询的顺序有任何性能影响吗?
- laravel - 从 Laravel Blade 动态页面标题中删除空格
- python - Python 将更改持久保存到函数的参数中而不返回(leetcode:“不返回任何内容,而是就地修改根”)
- python - Python循环中的正则表达式
- javascript - 单击路由器链接时强制重新渲染 vue 组件
- rss - Google 搜索新闻标签的 RSS 提要