Mat*_*rše 4 browser debugging automated-tests e2e-testing testcafe
在 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"
}
Run Code Online (Sandbox Code Playgroud)
我尝试从命令行启动测试
E:\testcafe-demo> npm run testcafe chrome demo.testcafe.ts --live
Run Code Online (Sandbox Code Playgroud)
与
E:\testcafe-demo> npm test chrome demo.testcafe.ts --live
Run Code Online (Sandbox Code Playgroud)
但结果总是相同的 - 测试完成后,浏览器关闭,并且没有任何迹象表明“实时”模式已被激活。
TestCafe Live 的功能已集成到 TestCafe 主产品中。
\n\n有关详细信息,请参阅\xc2\xa0实时模式\xc2\xa0。
\n\n确保将 --live 参数添加到脚本中:
\n\n "scripts": {\n "test": "testcafe chrome tests/ --live",\n "testcafe": "testcafe"\n },\nRun Code Online (Sandbox Code Playgroud)\n\n并使用 npm run test 运行测试。
\n\n这是另一个例子:
\n\n截图.js
\n\nimport { Selector } from \'testcafe\';\n\nfixture `My fixture`\n .page `http://devexpress.github.io/testcafe/example/`;\n\ntest(\'Take a screenshot of a fieldset\', async t => {\n await t\n .typeText(\'#developer-name\', \'Peter Parker\')\n .click(\'#submit-button\')\n .takeScreenshot({\n path: \'my-fixture/thank-you-page1.png\',\n fullPage: true\n });\n});\nRun Code Online (Sandbox Code Playgroud)\n\n命令行参数:
\n\ntestcafe chrome screenshot.js --live\nRun Code Online (Sandbox Code Playgroud)\n\n输出:
\n\nUsing locally installed version of TestCafe.\n\nLive mode is enabled.\nTestCafe now watches source files and reruns\nthe tests once the changes are saved.\n\nYou can use the following keys in the terminal:\n\'Ctrl+S\' - stops the test run;\n\'Ctrl+R\' - restarts the test run;\n\'Ctrl+W\' - enables/disables watching files;\n\'Ctrl+C\' - quits live mode and closes the browsers.\n\n\nWatching the following files:\n c:\\Temp\\screenshot.js\n Running tests in:\n - Chrome 79.0.3945.130 / Windows 10\n\n My fixture\n \xe2\x88\x9a Take a screenshot of a fieldset (screenshots: c:\\Temp\\screenshots\\my-fixture\\thank-you-page1.png)\n\n\n 1 passed (5s)\n\nMake changes to the source files or press Ctrl+R to restart the test run.\nRun Code Online (Sandbox Code Playgroud)\n