usu*_*arr 5 javascript testing automated-tests browser-automation testcafe
我正在使用带有 Java Script 的 Testcafe(免费版)。我想__test__在每个浏览器类型的单个浏览器实例(即 1 次登录)中运行我的所有测试用例(驻留在目录中的多个测试脚本中)。
我如何用 Testcafe 做到这一点?
const createTestCafe = require('testcafe')
let testcafe = null
let runner = null
createTestCafe('localhost', 1337, 1338)
.then(tc => {
testcafe = tc
const runner = testcafe.createRunner()
return runner
.src([ '__test__/*.js' ])
.browsers([ 'chrome:headless --no-sandbox --disable-gpu', 'safari' ])
.screenshots('./reports/screenshots/', true)
.run({
selectorTimeout: 10000,
assertionTimeout: 10000,
})
})
runner
.screenshots({
path: 'reports/screenshots/',
takeOnFails: true,
})
.then(failedCount => {
console.log('Tests failed: ' + failedCount)
testcafe.close()
})
.catch(error => {
console.log("An ERROR detected:" + error)
})
Run Code Online (Sandbox Code Playgroud)
这就是在 Dockerfile 上安装 chrome 的方式。有人能告诉我如何在 Dockerfile 上安装 Firefox 吗?
RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' && \
http_proxy=${http_proxy} https_proxy=${https_proxy} apt-get update && \
http_proxy=${http_proxy} https_proxy=${https_proxy} apt-get install -y --allow-unauthenticated google-chrome-stable && \
apt clean && rm -rf /var/lib/apt/lists/*
Run Code Online (Sandbox Code Playgroud)
一次性满足所有要求是不可能的。
1) 例如,chrome 有 1 个实例,safari 有 1 个实例,但所有测试都将在关闭浏览器之前运行。
您无法在 docker 映像上安装 Chrome 和 Safari Web 浏览器。可以只安装 Chromium 和 Firefox。有关更多信息,请参阅使用 TestCafe docker帮助主题。
2)如果测试失败,我想要截屏并计算测试失败的数量。但还想继续。
TestCafe 的Live 模式的工作方式相同,但在 docker 上不可用。
| 归档时间: |
|
| 查看次数: |
351 次 |
| 最近记录: |