Reputation: 1
I need help setting up TestCafe to run in Firefox & Edge. I am also interested in learning how to emulate other browsers/devices (mobile devices).
I am a QA Tester (not a Developer) new to TestCafe in need of some training material. I have Chrome (v 86.0.4240.75), Edge (v 41.16299.1480.0), & Firefox (v 83.0) installed locally. I recorded a test using Chrome and it runs successfully when the Run Configuration is set to Chrome and I am able to watch the test run to completion.
When the same test is run with the Run Configuration set to Firefox, a browser window does not open, but after a short while TestCafe indicates that the test ran to completion successfully. It is as if it were running headless, but that is not how I have it set.
When the same test is run with Run Configuration is set to Edge, an Edge browser window appears and loads the page to be tested, but the test does not progress beyond the 1st step nor does it fail. It just sits there as if it were run in Record mode waiting for me to tell it to progress, but it was set to run not record.
Can I get the test to run in non-Chrome browsers like I experience when running in Chrome?
Upvotes: 0
Views: 1160
Reputation: 6318
As I understand it, you are using TestCafe Studio. To emulate mobile devices in TestCafe Studio, please take a look at this article: https://docs.devexpress.com/TestCafeStudio/400189/user-interface/run-configurations-dialog
As for the issue with non-Chrome browsers, the cause is unclear. Please try running your tests using the command line without TestCafe Studio. For this, please check the directory where your TestCafe Studio is installed. In my case it is
C:\Program Files\TestCafe Studio\
.
Then please run the following command:
node <your_path_to_testcafe_studio>/resources/app.asar.unpacked/node_modules/testcafe/bin/testcafe <your_browser> <path_to_your_test_file>
.
For example, in my case the command will be:
node "C:/Program Files/TestCafe Studio/resources/app.asar.unpacked/node_modules/testcafe/bin/testcafe" firefox D:\projects\testcafe\test\functional\fixtures\api\raw\selector\testcafe-fixtures\new-fixture.testcafe
Please try to run this command and share the results.
Please also check that you are using the latest TestCafe Studio.
Upvotes: 4
Reputation: 15177
Yes, you can check the TestCafe docs about browsers.
Using simply: testcafe "firefox:path/to/firefox:headless" tests/sample-fixture.js
your test will run in Firefox (browser installed is required)
But, There is also another option to run tests using multiple browsers. This other way is execute tests using runner.
Following the docs (also into my project is implemented in this way), you can create a file like this:
const createTestCafe = require('testcafe');
let testcafe = null;
createTestCafe()
.then(tc => {
testcafe = tc;
// Start the runner
const runner = testcafe.createRunner();
// Start APP and wait 10s to ensure is up
runner.startApp('npm run dev', 10000);
return runner
// test folder
.src('./e2e/src/app.e2e-spec.js')
// Browsers where tests will be executed
.browsers([ /* List with your browsers */])
// Reporter to use if you want (optional)
.reporter('html', "./html-reporter/reports.html")
// Start tests
.run();
})
.then(_ => {
testcafe.close();
});
Is explained inline, but the idea is simply. Using TestCafe
API, create a runner
, set the options, and run the tests.
I've not added browser list. This is a personal election, you want FireFox and Edge, for example.
You can check into the docs the differents browsers and options.
Also, my list is something like this:
.browsers([
'chrome:headless:emulation:device=iphone X',
'firefox:headless:emulation:device=Samsung Galaxy S9',
// And so on ...
])
First option is the browser itself.
headless
this is optional and is used to run without open the browser window (Safari doesn't support it).
And device
is to emulate a device.
Also, into docs, is explained in a better way.
And executing this file using simply node runner.js
all test will be executed into every browser added to the list.
Upvotes: 3