google-chrome - Jenkins 中的 TestCafe 无法建立浏览器连接

标签 google-chrome jenkins automation e2e-testing 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 容器的原因。
这是我的 Jenkins 文件...
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 文档中,但很难找到并且没有完全解释。对于我的实例,我创建了自己的标志 --noSandbox在我的测试运行程序代码中添加了 --no-sandbox传递给 .browsers() 的参数的标志函数,如果它包含“ Chrome ”或“ Chrome ”

关于google-chrome - Jenkins 中的 TestCafe 无法建立浏览器连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51862602/

相关文章:

linux - 如何从用户输入的脚本中为命令设置 “fill in the blanks”?

jquery - Chrome : Seems to add an invisible border when hovering over a tr

javascript - 检查浏览器是否有 Pinterest Pin it 按钮

plugins - 如何在Jenkins中使用ANSIcolor插件?

php - laravel项目的CI/CD如何使其稳定

linux - 为了在 Bash/KSH 中实现自动化,自动将值传递给脚本菜单

java - 在 robotsium 脚本中使用 Rosource Id 单击按钮

Linux:登录帐户后 Chrome 崩溃

javascript - 您可以访问 Chrome 开发者网络选项卡数据吗?

jenkins - Jenkins 中的配置全局安全性缺少 JNLP 端口