簡體   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