我在Java脚本中使用Test咖啡馆(免费版本)。我希望在单个浏览器实例(即每次登录1次)中运行所有测试用例(驻留在__test__目录中的多个测试脚本中)。
我如何在Test咖啡馆中做到这一点呢?
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)
})这是如何在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/*发布于 2019-11-11 15:26:09
同时满足所有要求是不可能的。
例如,chrome的一个实例和safari的一个实例,但是所有的测试都会在关闭浏览器之前运行。
您不能在docker映像上安装Chrome和Safari web浏览器。只在上面安装Chromium和Firefox是可能的。有关更多信息,请参见使用TestCafe码头帮助主题。
2)如果测试失败,我希望屏幕截图和失败的计数数。但还是想继续。
TestCafe的活模式以同样的方式工作,但它在docker上是不可用的。
发布于 2019-12-04 10:37:14
这种情况下,需要使用会话处理。
在测试执行期间,Selenium WebDriver必须始终与浏览器交互以执行给定的命令。在执行时,还可能在当前执行完成之前,其他人在同一台机器和同一类型的浏览器中开始执行另一个脚本。
https://stackoverflow.com/questions/58757716
复制相似问题