Concurrent tests do not respect device
What is your Test Scenario?
- Set up a test to use the
browserchrome:emulation:device=iphone X;cdpPort=9223 - Use
--concurrency 3as an option - Run test
What is the Current behavior?
- The test will run, three browsers will open
- The first browser will be the correct Chrome emulation device (
iphone X) - The subsequent browsers will be just a normal desktop browser
What is the Expected behavior?
- All browsers that open should be in the Chrome emulation device
What is your web application and your TestCafe test code?
Your website URL (or attach your complete example):
Test URL: https://www.whatismybrowser.com/detect/how-big-is-my-web-browser Complete repo: https://github.com/kchung/testcafe-mobile-concurrency
Your complete test code (or attach your test files):
import { Selector } from 'testcafe';
fixture `Mobile concurrency 1`
.page `https://www.whatismybrowser.com/detect/how-big-is-my-web-browser`
test('Verify browser window size', async (t) => {
const PixelWidth = Selector('#pixels-width');
const PixelHeight = Selector('#pixels-height');
console.log(`Browser alias: ${t.browser.alias}`);
await t
.wait(2000)
.expect(PixelWidth.textContent).eql('375');
});
Your complete configuration file (if any):
{
"src": "./tests",
"browsers": "chrome:emulation:device=iphone X;cdpPort=9223",
"skipJsErrors": true,
"hostname": "localhost"
}
Your complete test report:
$ npm run test:concurrent
> [email protected] test:concurrent /Users/chung/Projects/testcafe-mobile-concurrency
> testcafe -c 3
Running tests in:
- Chrome 90.0.4430.212 / macOS 10.14.6 (Emulating iPhone X) (Emulating iPhone X)
Mobile concurrency 1
Browser alias: chrome:emulation:device=iphone X;cdpPort=9223
Browser alias: chrome:emulation:device=iphone X;cdpPort=9223
Browser alias: chrome:emulation:device=iphone X;cdpPort=9223
Browser alias: chrome:emulation:device=iphone X;cdpPort=9223
Browser alias: chrome:emulation:device=iphone X;cdpPort=9223
✖ Verify browser window size
1) AssertionError: expected '1200' to deeply equal '375'
+ expected - actual
-1200
+375
Browser: Chrome 90.0.4430.212 / macOS 10.14.6 (Emulating iPhone X) (Emulating iPhone X)
9 |
10 | console.log(`Browser alias: ${t.browser.alias}`);
11 |
12 | await t
13 | .wait(2000)
> 14 | .expect(PixelWidth.textContent).eql('375');
15 |});
16 |
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.1.js:14:37)
at asyncGeneratorStep (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.1.js:1:241)
at _next (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.1.js:1:579)
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.1.js:1:744)
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.1.js:1:485)
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.1.js:6:5)
Mobile concurrency 2
✖ Verify browser window size
1) AssertionError: expected '1200' to deeply equal '375'
+ expected - actual
-1200
+375
Browser: Chrome 90.0.4430.212 / macOS 10.14.6 (Emulating iPhone X) (Emulating iPhone X)
9 |
10 | console.log(`Browser alias: ${t.browser.alias}`);
11 |
12 | await t
13 | .wait(2000)
> 14 | .expect(PixelWidth.textContent).eql('375');
15 |});
16 |
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.2.js:14:37)
at asyncGeneratorStep (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.2.js:1:241)
at _next (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.2.js:1:579)
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.2.js:1:744)
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.2.js:1:485)
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.2.js:6:5)
Mobile concurrency 3
✓ Verify browser window size
Mobile concurrency 4
✓ Verify browser window size
Mobile concurrency 5
Browser alias: chrome:emulation:device=iphone X;cdpPort=9223
Browser alias: chrome:emulation:device=iphone X;cdpPort=9223
✓ Verify browser window size
Mobile concurrency 6
Browser alias: chrome:emulation:device=iphone X;cdpPort=9223
Browser alias: chrome:emulation:device=iphone X;cdpPort=9223
✖ Verify browser window size
1) AssertionError: expected '1200' to deeply equal '375'
+ expected - actual
-1200
+375
Browser: Chrome 90.0.4430.212 / macOS 10.14.6 (Emulating iPhone X) (Emulating iPhone X)
9 |
10 | console.log(`Browser alias: ${t.browser.alias}`);
11 |
12 | await t
13 | .wait(2000)
> 14 | .expect(PixelWidth.textContent).eql('375');
15 |});
16 |
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.6.js:14:37)
at asyncGeneratorStep (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.6.js:1:241)
at _next (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.6.js:1:579)
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.6.js:1:744)
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.6.js:1:485)
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.6.js:6:5)
Mobile concurrency 7
✖ Verify browser window size
1) AssertionError: expected '1200' to deeply equal '375'
+ expected - actual
-1200
+375
Browser: Chrome 90.0.4430.212 / macOS 10.14.6 (Emulating iPhone X) (Emulating iPhone X)
9 |
10 | console.log(`Browser alias: ${t.browser.alias}`);
11 |
12 | await t
13 | .wait(2000)
> 14 | .expect(PixelWidth.textContent).eql('375');
15 |});
16 |
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.7.js:14:37)
at asyncGeneratorStep (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.7.js:1:241)
at _next (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.7.js:1:579)
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.7.js:1:744)
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.7.js:1:485)
at <anonymous> (/Users/chung/Projects/testcafe-mobile-concurrency/tests/mobile.test.7.js:6:5)
Mobile concurrency 8
✓ Verify browser window size
Mobile concurrency 9
✓ Verify browser window size
4/9 failed (13s)
npm ERR! code ELIFECYCLE
npm ERR! errno 4
npm ERR! [email protected] test:concurrent: `testcafe -c 3`
npm ERR! Exit status 4
npm ERR!
npm ERR! Failed at the [email protected] test:concurrent script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/chung/.npm/_logs/2021-05-20T18_05_55_958Z-debug.log
Screenshots:
Steps to Reproduce:
- Clone the repo: https://github.com/kchung/testcafe-mobile-concurrency
- Run
npm test:concurrentto run a concurrent test - See the error
Your Environment details:
- testcafe version:
1.14.2 - node.js version:
v12.16.2 - command-line arguments:
testcafe - browser name and version:
chrome:emulation:device=iphone X;cdpPort=9223 - platform and version: macOS 10.14.6
Hello,
Thank you for your report. I have reproduced the behavior you described. I passed this question on to my colleagues. We will let you know once we have any results.
We found the cause of the breakdown. Multiple browser instances cannot use cdpPort in parallel. We decided to raise an error if the cdpPort parameter was specified with concurrency mode enabled. In the meantime, please omit cdpPort so TestCafe automatically assigns free ports for use in different browser instances.
@felis2803 thanks, removing cdpPort seems to fix my issue!