0

I'm trying to see if I can run my TestCafe cases in Headless Chrome browser using emulator device. I followed the instructions from TestCafe doc and I wasn't successful in it. (https://testcafe.io/documentation/402828/guides/concepts/browsers#use-emulation-in-headless-mode)

Below is the command I tried to use to run the same testcafe "chrome:headless:emulation:device=iphone X" ./tests/ --test-meta tags=Core

Actual - When I ran this command, the chrome headless browser was launched without the emulator. And the XPATH was failing since it wasn't the emulator.

Could anyone please let me know how to handle this?

Chaitanya Maligi
  • 217
  • 4
  • 7
  • 19

2 Answers2

1

I ran the following test:

import { ClientFunction } from 'testcafe';

const getUserAgent = ClientFunction(() => navigator.userAgent);

fixture `Fixture`;

test.meta('tags', 'Core')('test', async t => {
    console.log(await getUserAgent());
});

The test report indicates that emulated device is set correctly (see the userAgent string). test report

Could you please clarify how you determine that the emulator is not launched?

mlosev
  • 5,130
  • 1
  • 19
  • 31
0

I can do this with this:

testcafe "chrome:headless:emulation:device=iphone X;cdpPort=9223" tests/sample-fixture.js

And I can notice that is device emulator taking a screenshot.

Tyler2P
  • 2,324
  • 26
  • 22
  • 31