Browser offline mode

I want to start the browser connected and then switch it off(offline mode) at a specific moment.

Note that I don´t want to do it manually with the mouse because this is for creating an automated test with Katalon. So I need to be able to send the instruction to go offline somehow with a script.

Is there any way of using Katalon to do that in chrome?

Thanks very much for your help.

First note that there is a difference between Chrome and chrome.

Chrome: A browser from Google.

chrome: The controls that a browser provides (back button, home button, address bar, etc.)

What you are trying to do is manipulate elements inside the browser chrome (on Chrome, I believe). You cannot do that from Katalon’s native WebUI APIs. You may try the Katalon Windows APIs. Start here and look at the menu on the left for Windows Keywords. Note, I have never tried this.

The other thing you could try is the robot class but I’m not sure about that either. These guys may know more: @Brandon_Hein @kazurayam.

Enable Offline Cache Mode for Chrome 35
Visit about:flags.
Find “Enable Offline Cache Mode”, click on the “Enable” button and scroll down to the bottom and and click on the “Relaunch Now” button to restart Chrome.
Disconnect from the web and try loading in a page you previously visited.

1 Like

Hi @Brandon_Hein @kazurayam
Is there an option to make chrome browser offline using katalon. I had a task to run the test case by making a chrome browser offline and run some steps and then I need to make it back online again and run the rest of the test case. In the network tab of chrome developer tools, it has the option of making it offline. I want to make that offline using katalon. Thanks in advance.

Hi @srianoop.d,

You can emulate network emulation with Chrome DevTools Protocol (CDP) by installing: Chrome DevTools Protocol Integration plugin: https://store.katalon.com/product/144/Chrome-DevTools-Protocol-Integration

Sample script:

import com.github.kklisura.cdt.services.ChromeDevToolsService
import com.katalon.cdp.CdpUtils
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

WebUI.openBrowser('google.com')

ChromeDevToolsService cdts = CdpUtils.getService()

cdts.getNetwork().emulateNetworkConditions(true, 0, 0, 0)

WebUI.navigateToUrl('google.com')
2 Likes

Thanks @duyluong
I think this works for me.