I am using the below codes in my script but the internet is not getting disconnected.
1st try:
await browser.setNetworkConditions({ latency: 0, throughput: 0, offline: true });
2nd try:
browser.setNetworkConnection(0)// airplane mode off, wifi off, data off
3rd try:
await browser.throttle({ offline: true, downloadThroughput: 200 * 1024 / 8, uploadThroughput: 200 * 1024 / 8, latency: 20 })
Some links I have found in wdio official documentation but none of them are working.
Could anyone suggest to me the best way to do this?
visiting the https://webdriver.io/docs/api/browser/throttle/ they state the following "There are many presets available with default configurations for ease of use. They are offline, GPRS, Regular2G, Good2G, Regular3G, Good3G, Regular4G, DSL, WiFi, online.". By looking here: https://github.com/webdriverio/webdriverio/blob/6824e4eb118a8d20685f12f4bc42f13fd56f8a25/packages/webdriverio/src/commands/browser/throttle.js#L29 we can determine that the offline preset they use is:
So I would suggest trying the following:
Let me know if this helps!