google-chrome - Jenkins 中的 TestCafe 无法建立浏览器连接
问题描述
我在 jenkins 中有一个设置,它在代理中使用节点 docker 映像,在 jenkinsfile 中安装 chrome 和 testcafe,通过在 jenkinsfile 中运行 testcafe -b 并将 chrome 视为可用浏览器来验证。但是,每次我完全像在本地机器上一样使用 npm test 时,我都会得到....
Error: Unable to establish one
or more of the specified browser connections. This can be caused by
network issues or remote device failure.
我不确定我在哪里出错了,我不知道我按照文档说明设置自己的测试运行器是否相关,这就是我不使用 testcafe docker 容器的原因。这是我的詹金斯文件...
pipeline {
agent {
docker { image 'node:8.11-jessie' }
}
stages {
stage('Node check'){
steps {
sh 'node -v'
}
}
stage('Install Chrome') {
steps {
sh 'apt-get update'
sh 'apt-get install -y gconf-service libasound2 libappindicator3-1 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget'
sh 'rm -rf /var/lib/apt/lists/*'
sh 'wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb'
sh 'dpkg -i google-chrome*.deb'
}
}
stage('Npm installs') {
steps {
sh 'npm install -g testcafe testcafe-reporter-xunit'
sh 'npm install'
}
}
stage('browsers') {
steps {
sh 'testcafe -b'
}
}
stage('Test test'){
steps{
sh 'npm test -- --env=gamma --browsers=chrome:headless'
}
}
}
post {
always {
junit '**/testcafe/res.xml'
}
}
}
解决方案
Nvm,我应该使用 --no-sandbox chrome 标志,它在 testcafe 文档中,但很难找到并且没有完全解释。对于我的实例,我创建了自己的标志,如果它包含“chrome”或“chromium” ,则--noSandbox
在我的测试运行程序代码中将该--no-sandbox
标志添加到传递给函数的参数中.browsers()
推荐阅读
- windows - 如何通过 bash 在文件资源管理器中打开 Windows 启动文件夹?
- go - 无法在 Golang 的同一个包和文件夹中导入变量
- python-3.x - 如何在docker中为某些版本的python3安装pip
- php - 如何使用 curl 服务在邮件中附加存储在 laravel 存储中的文件或图像?
- python - Django - 返回一个主键列表及其引用的实体的另一个属性
- java - 具有特定密码的 PostgreSQL 随机错误
- events - 在 Hyperledger Sawtooth 浏览器客户端应用程序中订阅自定义事件
- c - 变量的类型是否存储在某处?它在哪里?
- sql - SQL:将 2 行合并为 1
- python - 在 django 用户模型中处理权限缓存