如何在 TestCafe 中结合设备仿真和无头模式

问题描述

我正在尝试查看是否可以使用模拟器设备在 Headless Chrome 浏览器中运行我的 testcafe 案例。 我按照 testcafe 文档的说明操作,但没有成功。 (https://testcafe.io/documentation/402828/guides/concepts/browsers#use-emulation-in-headless-mode)

下面是我试图用来运行相同的命令 testcafe "chrome:headless:emulation:device=iphone X" ./tests/ --test-Meta tags=Core

实际 - 当我运行此命令时,chrome 无头浏览器在没有模拟器的情况下启动。而且 XPATH 失败了,因为它不是模拟器。

谁能告诉我如何处理这个问题?

解决方法

我进行了以下测试:

import { ClientFunction } from 'testcafe';

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

fixture `Fixture`;

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

测试报告表明模拟设备设置正确(请参阅 userAgent 字符串)。 test report

您能否澄清一下您如何确定模拟器未启动?