问题
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