在Testcafe中进行测试时,保持浏览器处于打开状态 [英] Keep browser open while developing a test in Testcafe

查看:165
本文介绍了在Testcafe中进行测试时,保持浏览器处于打开状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

How to keep the browser window open after a test executes in Testcafe?

论坛上有一个问题实时Testcafe 版本,但它似乎已被弃用.

There was a question on the forum here that brought me to a live Testcafe version, but it seems to be deprecated.

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

I wish to keep the browser window open to see the elements while I'm developing the test.

更新:

这是我的配置文件:

{
  "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"
}

我尝试从命令行开始测试,

I tried starting the tests from the command line with

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

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

但是结果始终是相同的-测试完成后,浏览器关闭,并且没有激活实时"模式的指示.

but the result is always the same - after the test is finished, the browser is closed and there is no indication "live" mode was being activated.

推荐答案

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

Features from TestCafe Live were integrated into the main TestCafe product.

请参见实时模式有关更多信息.

请确保在脚本中添加--live参数:

Make sure to add the --live argument into your script:

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

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

And run your tests using 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.

这篇关于在Testcafe中进行测试时,保持浏览器处于打开状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆