“setNetworkConditions” in protractor e2e tests says not a function

僤鯓⒐⒋嵵緔 提交于 2019-12-23 04:58:19

问题


I am trying to use the

driver.setNetworkConditions({ offline : true });

in my code, but it says that Failed: _protractor.browser.driver.setNetworkConditions is not a function.

Here is my code to access it.

     import { browser } from 'protractor';

        describe('disable browser network', () => {
            "use strict";
            let browserA = browsers.a;
            it('should disable chrome network', () => {
                browserA.ignoreSynchronization = true;
                browser.driver.setNetworkConditions({ offline: true });
                //..... my other functionality here
            });
           afterAll(() => {
           browserA.quit();
           });
        });


回答1:


I have found the solution to this, actually I just had to update my npm protractor package globally

npm install protractor -g

and one more thing was to update the package version of protractor to 5.2.0 in package.json and again run the npm install command to update the node_modules

Then this thing work very well.

browser.driver.setNetworkConditions({
            offline: true, //I needed to set it offline intentionally
            latency: 150,
            download_throughput: 450 * 1024,
            upload_throughput: 150 * 1024
        });


来源:https://stackoverflow.com/questions/47486400/setnetworkconditions-in-protractor-e2e-tests-says-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!