testcafe

Keep browser open while developing a test in Testcafe

南笙酒味 提交于 2021-01-27 20:00:39
问题 How to keep the browser window open after a test executes in 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. Update: This is my config file: { "name": "testcafe-demo", "version": "1.0.0", "description": "", "main": "index.js", "dependencies": { "testcafe": "^1.8.2" }, "devDependencies": {}, "scripts": { "test": "testcafe chrome

How can I inject parameters into a TestCafé test?

徘徊边缘 提交于 2021-01-27 17:55:44
问题 Scenario: I run TestCafé wrapped in code, using the API I have a test I want to parameterize, testing with different dynamic values. Problem Testcafé has no support for sending parameters to a test. Is there a way to inject values? 回答1: You can use process.env to pass parameters to TestCafe tests from your runner script. //test.js const createTestCafe = require('testcafe'); (async => { process.env.foo = 'bar'; const testcafe = await createTestCafe(); await testcafe .createRunner() .src('test

How do I pass variable data between tests

浪子不回头ぞ 提交于 2021-01-27 13:21:31
问题 I am trying to do something similar to this post on TestCafe I am generating a random email in my helper.js file. I would like to use this random email to log in the test.js file. This is how I am creating my email in the helper.js var randomemail = 'test+' + Math.floor(Math.random() * 10000) + '@gmail.com' This is how I want to use it in my test.js file .typeText(page.emailInput, randomemail) I have tried several things without luck. How could I go about using the generated email in my test

How do I debug a Testcafe browser running in a testcafe/testcafe docker container?

孤者浪人 提交于 2021-01-27 13:20:41
问题 Got a test for a React app's login function in a Page class: async login(t) { console.log('starting login...'); debugger; this.logBrowserMessages(t); await this.loginModal({ visibilityCheck: true }); await t .expect(this.loginModal.visible) .ok() // then log the user in etc... And the test, which passes when running locally but fails in the container test.requestHooks(mock)('user can log in', async t => { await page.login(t); // Make sure test user's orders render. await t.expect(page.orders

Is it possible to use the TestCafe .meta object to skip tests running from the cli

ぃ、小莉子 提交于 2021-01-27 12:11:55
问题 I'm using TestCafe to run my integration tests. I know it has the test.skip function, which is great for when I'm testing locally and want to skip a set of tests I don't need/want to run... but I was wondering if there was a way to run ALL TESTS except --test-meta environmentSpecific=true etc? We have a number of different environments, and I'm looking for a simple way to skip tests via the CLI, depending on the environment we're targeting for the build. 回答1: Yes, you can do it using the

Run testcafe headless when passing custom args to Chrome binary via testcafe-browser-tools

强颜欢笑 提交于 2021-01-27 12:10:25
问题 Running testcafe inside a Vagrant VM, which is mostly working. However, Chrome doesn't start properly in this environment with hardware acceleration enabled, so I have to start it with the command line flag --disable-gpu . I'm leveraging the 'testcafe-browser-tools' package to accomplish this, by overriding the default browser command via the Runner class in the TestCafe API. This all works fine for the case of running TestCafe with it opening a browser window, but I've not been able to

How to get the json response of a RequestLogger

China☆狼群 提交于 2021-01-27 06:10:50
问题 RequestLogger A have this test outside the main test controller, using page model and this recipe. /** Used to get the periodic analytic id. Whenever we are viewing an asset, the server must respond with an id. This id is later used by the client, to send periodic analytics. @param {object} t Testcafe's test controller @param {object} logger A testcafe's RequestLogger. @returns {string} Returns the periodic analytic id. */ async getPeriodicAnalyticId(t, logger) { const logPrefix = 'Get

How to get the json response of a RequestLogger

廉价感情. 提交于 2021-01-27 06:10:13
问题 RequestLogger A have this test outside the main test controller, using page model and this recipe. /** Used to get the periodic analytic id. Whenever we are viewing an asset, the server must respond with an id. This id is later used by the client, to send periodic analytics. @param {object} t Testcafe's test controller @param {object} logger A testcafe's RequestLogger. @returns {string} Returns the periodic analytic id. */ async getPeriodicAnalyticId(t, logger) { const logPrefix = 'Get

How to override standard testcafe errors?

末鹿安然 提交于 2020-12-15 03:26:39
问题 I need to override standard testcafe error messages by adding there Selector's input locator - this way I will know more about failure and can debug that manually at least by manually checking ability for selector to be found. When I try just to catch error by this code: try { const selector = Selector('basdf') await t.click(selector); } catch (e) { console.log(e); } I'm getting this object: { code: 'E24', isTestCafeError: true, callsite: CallsiteRecord { filename: '/Users/myPath/helper_test