testcafe

How to get the testCafe exit code

馋奶兔 提交于 2019-12-13 13:41:56
问题 I am having an issue running Testcafe through cucumber. for whatever reason, When I run testCafe through cucumber, the process will always exit with exit code 0 even in the test fails. If I run puppeteer through cucumber I don't get this issue. I am thinking that this behavior is due to the way I have things set up in my hooks file where I am not properly interpreting the test cafe exit code. In my hooks file, I am creating a testCafe runner and in my Before hook and then closing it during my

How do I use an array I've created within my Test file

纵饮孤独 提交于 2019-12-13 11:15:07
问题 So I have created a js array for a list of postcodes. The array is as below in the code: - //postcode.js file var postcode = [ "b28 8ND", "b49 6BD", "b28 0ST", "b31 4SU", "B92 9AH", ]; What I need to do is in my test randomly select a postcode for this js file to enter into a text field when running my automation tests. How do I go about doing this? An example would be much appreciated as I can't find much on the internet & I'm quite new to TestCafe & javascript. Below is what I have in my

TestCafe ClientFunction TypeError error as document is undefined

妖精的绣舞 提交于 2019-12-11 13:41:52
问题 I can successfully execute the following .click: const clickMockContinueButton = ClientFunction(() => document.getElementsByName("paymentGatewayIframeReturnSubmit")[0].click()) by calling it with: await clickMockContinueButton(); But even after the successful .click I get a TypeError: An error occurred in ClientFunction code: TypeError: document.getElementsByName(...)[0] is undefined What am I doing wrong here? * EDIT with workaround * Seems there is a bug in my mocked page when I use either

Using testCafe 'requestLogger' to retrieve chrome performance logs fails

[亡魂溺海] 提交于 2019-12-11 12:43:12
问题 This is in continuation of this thread: Is there a way in TestCafe to validate Chrome network calls? Here is my testCafe attempt to retrieve all the network logs(i.e. network tab in developer tools) from chrome. I am having issues getting anything printed on console. const logger = RequestLogger('https://studenthome.com',{ logRequestHeaders: true, logRequestBody: true, logResponseHeaders: true, logResponseBody: true }); test ('My test - Demo', async t => { await t.navigateTo('https://appURL

TestCafe docker- unable to run tests using runner class

♀尐吖头ヾ 提交于 2019-12-11 05:44:05
问题 I have all my tests running in docker container and it works fine. Since, I have a few test files which needs concurrent tests and a file which doesn't need concurrent test that is the reason I need to create a test runner to run my tests. Here is what my test runner class looks like: const createTestCafe = require('testcafe'); let testcafe = null; createTestCafe('localhost', 1337, 1338) .then((tc) => { testcafe = tc; const runner1 = testcafe.createRunner(); const runner2 = testcafe

How do you prevent the tests from stopping on the first failed test case?

谁说我不能喝 提交于 2019-12-11 03:38:01
问题 I'm attempting to check if certain pieces of content are present, on different pages. For example: const contentCount = Selector('.some-element').childElementCount .expect(contentCount).gte(1, 'The related content is missing.') ... Which works fine, except that the testing stops after the first assertion fails. This isn't ideal as I'm trying to generate a report that shows ALL of the failed assertions at once. How do I get the test to keep running after a failed assertion? 回答1: Answering your

Check for value within test of TestCafe

杀马特。学长 韩版系。学妹 提交于 2019-12-10 22:33:54
问题 I use TestCafe to automate testing a specific function. In this function, the user is only allowed to have 5 entries. On the site is a label that indicates how many entries are left. When the user already has 5 entries it should delete one in order to test adding a new one. The html markup of the page is: <p class="pull-left text-muted">5 / 5 possible entries</p> Now I want to get exactly this string to make a little if/else with JavaScript to delete an entry when it says 5 / 5 possible

TestCafe - The browser always starts in clean slate between the tests. How to override this so that browser remembers cache, user settings and storage

醉酒当歌 提交于 2019-12-10 21:44:22
问题 The browser between the Tests is always open in a clean slate. The Login is remembered in my application as Authentication persists but as the browser is opened in clean slate always, I have to perform Login in Before hook of all Fixtures. Is there some way I can open browser so that user settings, cache, local and session storage are remembered? 回答1: TestCafe doesn't offer a way to store the page state between tests and encourages writing independent tests. However, Roles API may meet some

How to close testcafe runner

佐手、 提交于 2019-12-10 19:34:05
问题 I'm using Testcafe runner to execute some tests i got. When everything is finished the console remains executing the script forever. Here is my code: createTestCafe('localhost', 1337, 1338) .then(tc => { testcafe = tc; runner = testcafe.createRunner(); return runner .src(['offerRefresh.js']) .browsers(['nightmare']) .screenshots('./screenshots', true) .run(); }) .then(failedCount => { console.log('Tests failed: ' + failedCount); testcafe.close(); }); The console remains like this: Tests

Selecting elements from DOM

你。 提交于 2019-12-10 18:46:43
问题 On my page contents, I have multiple cards organized as a grid __________________ | ____ ____ | | | | | | | | | | | | | | |____| |____| | | | | ____ ____ | | | | | | | | | | | | | | |____| |____| | |__________________| My issue is that each card container has the same class, and I want to select a distinct element inside a container. Example: <div class="parent-container"> <div class="container"> <h2> Distinct title 1 </h2> </div> <div class="container"> <div class="another-container">