Ry-ry
Ry-ry

Reputation: 278

How do you set network throttling in selenium using javascript?

How do you set the network throttling settings in chrome using selenium and javascript

Upvotes: 2

Views: 2152

Answers (1)

Tom Somerville
Tom Somerville

Reputation: 126

It did take me a bit of time to figure this out as well, but this seemed to work for me

  driver = await new Builder()
            .forBrowser(engine)
            .usingServer(testConfig.seleniumServer + 'wd/hub')
            .setChromeOptions(new chrome.Options()) //.headless()
            .build();
        driver.setNetworkConditions({
            offline: false,
            latency: 15, // Additional latency (ms).
            download_throughput: 50 * 1024, // Maximal aggregated download throughput.
            upload_throughput: 50 * 1024 // Maximal aggregated upload throughput.
        });

Upvotes: 1

Related Questions