在 Testcafe 中开发测试时保持浏览器打开
Keep browser open while developing a test in Testcafe
如何在 Testcafe 中执行测试后保持浏览器 window 打开?
论坛 here that brought me to a live Testcafe 版本有问题,但似乎已弃用。
我希望在开发测试时保持浏览器 window 打开以查看元素。
更新:
这是我的配置文件:
{
"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
但结果总是一样 - 测试完成后,浏览器关闭并且没有任何迹象表明 "live" 模式已被激活。
TestCafe Live 的功能已集成到主要的 TestCafe 产品中。
有关详细信息,请参阅Live Mode。
确保将 --live 参数添加到您的脚本中:
"scripts": {
"test": "testcafe chrome tests/ --live",
"testcafe": "testcafe"
},
并且 运行 你的测试使用 npm 运行 测试。
这是另一个例子:
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.
如何在 Testcafe 中执行测试后保持浏览器 window 打开?
论坛 here that brought me to a live Testcafe 版本有问题,但似乎已弃用。
我希望在开发测试时保持浏览器 window 打开以查看元素。
更新:
这是我的配置文件:
{
"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
但结果总是一样 - 测试完成后,浏览器关闭并且没有任何迹象表明 "live" 模式已被激活。
TestCafe Live 的功能已集成到主要的 TestCafe 产品中。
有关详细信息,请参阅Live Mode。
确保将 --live 参数添加到您的脚本中:
"scripts": {
"test": "testcafe chrome tests/ --live",
"testcafe": "testcafe"
},
并且 运行 你的测试使用 npm 运行 测试。
这是另一个例子:
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.