gpt4 book ai didi

debugging - 在 Testcafe 中开发测试时保持浏览器打开

转载 作者:行者123 更新时间:2023-12-05 01:37:58 31 4
gpt4 key购买 nike

如何在 Testcafe 中执行测试后保持浏览器窗口打开?

论坛有人提问here这把我带到了a live Testcafe版本,但它似乎已被弃用。

我希望在开发测试时保持浏览器窗口打开以查看元素。

更新:

这是我的配置文件:

{
"name": "testcafe-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"testcafe": "^1.8.2"
},
"devDependencies": {},
"scripts": {
"test": "testcafe chrome tests/",
"testcafe": "testcafe"
},
"author": "mmrse",
"license": "ISC"
}

我尝试从命令行开始测试

E:\testcafe-demo> npm run testcafe chrome demo.testcafe.ts --live

E:\testcafe-demo> npm test chrome demo.testcafe.ts --live

但结果总是一样的 - 测试完成后,浏览器关闭并且没有任何迹象表明“实时”模式已被激活。

最佳答案

TestCafe Live 的功能已集成到主要的 TestCafe 产品中。

参见Live Mode获取更多信息。

确保将 --live 参数添加到您的脚本中:

  "scripts": {
"test": "testcafe chrome tests/ --live",
"testcafe": "testcafe"
},

然后使用 npm run test 运行测试。

这是另一个例子:

screeshot.js

import { Selector } from 'testcafe';

fixture `My fixture`
.page `http://devexpress.github.io/testcafe/example/`;

test('Take a screenshot of a fieldset', async t => {
await t
.typeText('#developer-name', 'Peter Parker')
.click('#submit-button')
.takeScreenshot({
path: 'my-fixture/thank-you-page1.png',
fullPage: true
});
});

命令行参数:

testcafe chrome screenshot.js --live

输出:

Using locally installed version of TestCafe.

Live mode is enabled.
TestCafe now watches source files and reruns
the tests once the changes are saved.

You can use the following keys in the terminal:
'Ctrl+S' - stops the test run;
'Ctrl+R' - restarts the test run;
'Ctrl+W' - enables/disables watching files;
'Ctrl+C' - quits live mode and closes the browsers.


Watching the following files:
c:\Temp\screenshot.js
Running tests in:
- Chrome 79.0.3945.130 / Windows 10

My fixture
√ Take a screenshot of a fieldset (screenshots: c:\Temp\screenshots\my-fixture\thank-you-page1.png)


1 passed (5s)

Make changes to the source files or press Ctrl+R to restart the test run.

关于debugging - 在 Testcafe 中开发测试时保持浏览器打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60303335/

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