簡體   English   中英

chrome遠程接口ECONNREFUSED 127.0.0.1:9222

[英]chrome remote interface ECONNREFUSED 127.0.0.1:9222

我正在使用 Testcafe,它不直接支持訪問 Chrome 開發工具。 我的目標是切斷網絡,以便我可以在網站上看到錯誤對話框。 這是我寫的代碼。 TestCafe opens at a different url Here is the 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

請在一個類似的問題上尋找: How to run TestCafe tests with throttling connection?

此外,在 TestCafe 存儲庫中,我們有一個模擬網絡節流的測試: https://github.com/DevExpress/testcafe/blob/61f3703d50ef8cc64331d09659837c52a9aae862/test/functional/fixtures/regression/9-testcafe. js

import { ClientFunction } from 'testcafe';

fixture `Should reconnect with bad network conditions (GH-3929)`
    .page `http://localhost:3000/fixtures/regression/gh-3929/pages/index.html`;

const getClickCount = ClientFunction(() => {
    return window.clickCount;
});

test(`Click action with bad network conditions`, async t => {
    const browserConnection = t.testRun.browserConnection;
    const browser           = browserConnection.provider.plugin.openedBrowsers[browserConnection.id];
    const client            = await browser.browserClient.getActiveClient();

    const networkConditions = {
        offline:            true,
        latency:            10,
        downloadThroughput: 100000,
        uploadThroughput:   100000
    };

    await client.Network.emulateNetworkConditions(networkConditions);

    setTimeout(() => {
        networkConditions.offline = false;

        client.Network.emulateNetworkConditions(networkConditions);
    }, 5000);

    const expectedClickCount = 10;

    for (let i = 0; i < expectedClickCount; i++)
        await t.click('button');

    const actualClickCount = await getClickCount();

    await t.expect(actualClickCount).eql(expectedClickCount);
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM