繁体   English   中英

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

[英]Keep browser open while developing a test in 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"
}

我尝试从命令行开始测试

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.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM