gpt4 book ai didi

typescript - 如何使用 TestCafe 在失败时截屏

转载 作者:行者123 更新时间:2023-12-05 07:17:01 27 4
gpt4 key购买 nike

我试图在 Testcafe + gherkin 中截屏失败,但没有成功。我已经设置了一个配置文件:

{
"browsers": "firefox",
"screenshots": {
"path": "reports/screenshots/",
"takeScreenshotsOnFails": true,
"pathPattern": "${TIME}.png"
},
"reporter": [
{
"name": "spec"
},
{
"name": "cucumber-json",
"output": "reports/generatedReports/newReport.json"
}
],
"pageLoadTimeout": 1000
}

但是屏幕截图没有出现。其他线路像浏览器等一样工作。

我应该使用:

   await t.takeScreenshot("reports/SCREENSHOT.png");

但是如何只在失败时才执行呢?

最佳答案

takeScreenshotsOnFails 已在 newer versions 中替换为 takeOnFails .

你的配置文件应该是这样的:

{
"browsers": "firefox",
"screenshots": {
"path": "reports/screenshots/",
"{
"browsers": "firefox",
"screenshots": {
"path": "reports/screenshots/",
"takeOnFails": true,
"pathPattern": "${TIME}.png"
},
"reporter": [
{
"name": "spec"
},
{
"name": "cucumber-json",
"output": "reports/generatedReports/newReport.json"
}
],
"pageLoadTimeout": 1000
}

关于typescript - 如何使用 TestCafe 在失败时截屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58936683/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com