testcafe

How to do fs.existsSync(path) with Timeout

∥☆過路亽.° 提交于 2020-01-02 09:41:33
问题 I'm writing an automated test script using TestCafe and Node.JS. One of the tests is to download a file and validate that the download is complete. I don't want to write a hard coded await t.wait(4000); because since my test is based on a data driven framework I can feed it lots of data with lots of different files and file types. So the file size could vary by extreme amounts from a few Kilobytes to Gigabytes. So writing await t.wait(4000); might work for one test case but will almost

How to do fs.existsSync(path) with Timeout

时光毁灭记忆、已成空白 提交于 2020-01-02 09:41:00
问题 I'm writing an automated test script using TestCafe and Node.JS. One of the tests is to download a file and validate that the download is complete. I don't want to write a hard coded await t.wait(4000); because since my test is based on a data driven framework I can feed it lots of data with lots of different files and file types. So the file size could vary by extreme amounts from a few Kilobytes to Gigabytes. So writing await t.wait(4000); might work for one test case but will almost

Select OK button from N'th modal opened in testcafe

旧巷老猫 提交于 2019-12-31 02:02:15
问题 I open two modals in my testing, and I want to be able to click on the "OK" button in the second modal (the second selected element in the below html). My current code is : import { waitForReact } from 'testcafe-react-selectors'; import { Selector } from 'testcafe'; fixture `App tests` .page('http://localhost:3000/') .beforeEach(async () => { await waitForReact(); }); test('Can open and accept all pop ups', async t => { //open first modal await t .click('#LayerAddingPopUpButtonID'); //select

master runner in testcafe for several other runners?

℡╲_俬逩灬. 提交于 2019-12-24 07:39:11
问题 I have several runners which are using promise.race to complete the testcase at a particular time Say I have runner1.js, runner2.js runner3.js, how do I create a master runner so that I can run all these runners together? const createTestCafe = require('testcafe'); let testcafe = null; // createTestCafe('localhost', 1337, 1338) createTestCafe() .then(tc => { testcafe = tc; //create test runner for configuring and launching test tasks const runner = testcafe.createRunner(); return runner //run

Where are scripts in injectScripts injected in TestCafé tests?

假装没事ソ 提交于 2019-12-24 03:56:05
问题 I am setting up TestCafé tests programmatically and I use the injectScripts config on the Runner class to inject functions. According to the documentation, these scripts are added to the header of the tested page. Is it possible to invoke the functions from the test itself? I haven't found a way to do it. I can see that the scripts map is accessible inside the test and I can log out the content by doing console.log(t.testRun.opts.clientScripts) But it would be utterly ugly to parse this map

Testcafe example to assert file download

与世无争的帅哥 提交于 2019-12-24 03:51:10
问题 I want to write a fixture to simulate the export file and make sure a file is downloaded from browser actions. any example? NA 回答1: There's not a fancy way check if the download has finished, TestCafe is somewhat limited in its ability to control the download ability in the browser. import fs from 'fs'; const fileName = 'junk.txt'; const downloadLocation = 'C:\\Wherever\\Downloads\\'; const fileDLUrlBase = 'https://example.com/downloads/'; fixture('download test fixture'); test('download test

How to click unrendered virtualized element in TestCafe

拜拜、爱过 提交于 2019-12-24 03:47:10
问题 I'm using react-virtualized for a lengthy (1000+) list of items to select from. And I'm trying to set up an end to end test that requires clicking on one of the elements that are not currently rendered. Ordinarily, I'd simply use something like: await t.click( ReactSelector('ListPage') .findReact('ListItem') .nth(873) // or .withText(...) or .withProps(...) ) But because only a small subset of the ListItem s are rendered, TestCafe fails to find the desired element. I've been trying to figure

In TestCafe is there a way to know if the test passed or failed in after hook?

只愿长相守 提交于 2019-12-23 21:27:52
问题 I am trying to mark tests as pass/failed through a rest API (Zephyr) while my testcafe tests are running. I was wondering if it's possible in the after or afterEach hook to know if the test passed/failed so that I can run some script based on the result. Something like: test(...) .after(async t => { if(testFailed === true) { callApi('my test failed'); } }) 回答1: I see two ways in which to solve your task. First, do not subscribe to the after hook, but create your own reporter or modify the

cucumber-js parse error when run on Jenkins

不问归期 提交于 2019-12-23 18:50:53
问题 I am trying to setup a jenkins pipeline step to runs some test scenarios using cucumber-js but I am getting an error back from the build as follows: Error: Parse error in 'e2e/definitions/login.js': (1:1): expected: #EOF, #Language, #TagLine, #FeatureLine, #Comment, #Empty, got 'const { Given, When, Then } = require('cucumber');' The command being run in the pipeline step is as follows: cucumber-js e2e/features/**/*.feature --require e2e/**/*.js The opening lines of the login.js file the

How to do 'beforeEach' only at Fixture level and not for each test under that fixture

。_饼干妹妹 提交于 2019-12-23 16:26:38
问题 I want to run 'beforeEach' only at the fixture level and not for each test under that fixture fixture `Fixture A for Use Case1` .beforeEach(login) test('A Test 1', async t => { await t --- }); test('A Test 2', async t => { await t --- }); fixture `Fixture B for Use Case2` .beforeEach(login) test('B Test 1', async t => { await t --- }); test('B Test 2', async t => { await t --- }); test('B Test 3', async t => { await t --- }); What Is Happening The login function is being run before every test