在Testcafe中执行测试后,如何保持浏览器窗口打开?
有在论坛上的一个问题在这里是把我带到现场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参数:
"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.
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句