我正在使用 Testcafe,它不直接支持访问 Chrome 开发工具。我的目标是切断网络,以便我可以在网站上看到错误对话框。这是我写的代码。TestCafe 在不同的 url 打开 这是 URL: http: //192.168.0.123 :52678/someRandomStringHere/https://abcdefgh.com/abcdefgh/
我无法为此 url 配置参数。仅供参考,端口号更改,它不是固定的。有人可以帮我解决这个问题。
//Performing some actions using Testcafe here
let config = {
offline: true,
latency: 100,
downloadThroughput: 750 * 1024 / 8,
uploadThroughput: 250 * 1024 / 8
};
const CDP = require('chrome-remote-interface');
const client = await CDP();
const {Network} = client;
await Promise.all([
Network.enable()
]);
Network.emulateNetworkConditions(config);
//Checking if the error is present or not in website after cutting the network