Protractor: running chrome with mains choke on

The network throttling feature from Chrome DevTools is available in ChromeDriver-2.26 + to address this issue . How can I specify this in our protractor config file?

Based on a search, I've tried variations of a couple of things in the config file. I added property networkConnectionEnabled

and block prefs

for chromeOptions as shown below. (Note that I did not do both of them at the same time.)

multiCapabilities: [
    {
        'browserName': 'chrome',
        'platform': 'ANY',
        'networkConnectionEnabled': {'type': 'GPRS'},
        'chromeOptions': {
            args: [
                '--lang=en',
                '--window-size=1280,1024'
            ],
            prefs: {
                'net.throttling_enabled': 'true,50,20'
            }
        }
    }
],

      

Second option I tried based on what I found here (line 1983). None of these change the behavior of the progon which, when I manually check and set the throttling, causes a certain condition in my code.

Edit: also tried adding something like this underchromeOptions: mobileEmulation: {networkConnectionEnabled: true, networkThrottle: '2G'}

+3


source to share


1 answer


As per changelog, APIs for managing network emulation in Chrome were added in Selenium 3.4.0. And they are available in Protract 5.2.0 or newer.

The network conditions can be configured as follows:



browser.driver.setNetworkConditions({
    offline: false,
    latency: 5, // Additional latency (ms).
    download_throughput: 500 * 1024, // Maximal aggregated download throughput.
    upload_throughput: 500 * 1024 // Maximal aggregated upload throughput.
});

      

This code should be placed protractor.conf.js

inside onPrepare

.

+1


source







All Articles