Держите браузер открытым при разработке теста в Testcafe - PullRequest
1 голос
/ 19 февраля 2020

Как сохранить окно браузера открытым после выполнения теста в Testcafe?

На форуме возник вопрос здесь , который привел меня к живому Testcafe версия, но кажется, что она устарела.

Я хочу sh, чтобы держать окно браузера открытым, чтобы видеть элементы во время разработки теста.

Обновление:

Это мой конфигурационный файл:

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

но результат всегда один и тот же - после завершения теста браузер закрывается и нет индикации, что активирован "живой" режим.

1 Ответ

3 голосов
/ 20 февраля 2020

Функции из TestCafe Live были интегрированы в основной продукт TestCafe.

См. Режим Live для получения дополнительной информации.

Обязательно добавьте аргумент --live в ваш скрипт:

"scripts": {"test": "testcafe chrome tests / --libe", "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.
...