We need to work on F12 -> developer options automation using the chrome browser facing few issues need guidance

Type your question here. Then choose a suita Issue 1 : We prepared a code and imported required jar files and facing the issue , we are not able to see android and some execution options and even not able to execute , even if we click on execute on chrome browser nothing happens

Noted an issue even after importing the required jar files getDevTools() method is not recognized by katalon 8.3.5 version . Need guidance for this issue



Issue2:

Since getDevTools() method is not recognized we tried to use different way for devtools implementation

SmartWaitWebDriver smartWaitWebDriver = **new** SmartWaitWebDriver(driver)

println("inside loop of network")

smartWaitWebDriver.startChromeWithNetworkCapture()

=============

**package** com.clario.webui

**import** org.openqa.selenium.chrome.ChromeDriver

**import** org.openqa.selenium.chrome.ChromeOptions

**import** org.openqa.selenium.devtools.DevTools

**import** org.openqa.selenium.devtools.v125.network.Network

**import** com.kms.katalon.core.annotation.Keyword

**import** com.kms.katalon.core.webui.driver.DriverFactory

**import** java.util.Optional

**import** org.openqa.selenium.By

**import** org.openqa.selenium.WebDriver;

**import** org.openqa.selenium.WebElement

**import** java.util.List

**import** java.util.Set

**import** java.util.Optional

**public** **void** startChromeWithNetworkCapture() {

// Create a DevTools instance

DevTools devTools = **new** DevTools(**this** );

// Start the DevTools session

devTools.createSession();

// Enable network monitoring

devTools.send(Network.*enable*(Optional.*empty*(), Optional.*empty*(), Optional.*empty*()));

// Add a listener for network requests

devTools.addListener(Network.*requestWillBeSent*()) { params ->

System.***out*** .println("Request URL: " + params.getRequest().getUrl())

System.***out*** .println("Request Method: " + params.getRequest().getMethod())

System.***out*** .println("Request Headers: " + params.getRequest().getHeaders())

System.***out*** .println("Request Post Data: " + params.getRequest().~~getPostData~~())

System.***out*** .println("Request Timestamp: " + params.getTimestamp())

}

}

Error we received:

024-06-06 16:21:12.951 ERROR c.k.katalon.core.main.TestCaseExecutor - ❌ Test Cases/MicroPortal/Dispense/4 FAILED.

Reason:

groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.clario.webui.SmartWaitWebDriver(com.kms.katalon.core.webui.driver.SmartWaitWebDriver)

Issue 3:

So the previous way was not supporting we tried a another way using proxy but we are getting facing below issue (SSL certificate issue, site is displaying as not secured one)

ERROR:

2024-06-06 15:51:31.074 ERROR o.l.proxy.impl.ClientToProxyConnection - (NEGOTIATING_CONNECT) [id: 0xb5271f8a, L:0.0.0.0/0.0.0.0:60196 ! R:/fe80:0:0:0:910e:5e67:8e0d:3b2%4:60214]: Caught an exception on ClientToProxyConnection

io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: Received fatal alert: certificate_unknown

Code we prepared:

// Start BrowserMob Proxy

BrowserMobProxy proxy = **new** BrowserMobProxyServer()

proxy.start(0)

println("Proxy started on port: " + proxy.getPort())

// Get the Selenium proxy object

Proxy seleniumProxy = ClientUtil.*createSeleniumProxy*(proxy)

// Configure Chrome options

ChromeOptions options = **new** ChromeOptions()

options.addArguments("–ignore-certificate-errors")

options.addArguments("–allow-running-insecure-content")

options.addArguments("–allow-insecure-localhost")

options.setProxy(seleniumProxy)

// Start the Chrome browser with configured options

WebDriver driver = **null**

**try** {

driver = **new** ChromeDriver(options)

DriverFactory.*changeWebDriver*(driver) // Set the WebDriver instance in Katalon

println("Browser launched successfully")

} **catch** (Exception e) {

println("Failed to launch browser: " + e.getMessage())

**throw** e

}

// Enable more detailed HAR capture, if desired (see CaptureType for the complete list)

proxy.enableHarCaptureTypes(CaptureType.***REQUEST_CONTENT*** , CaptureType.***RESPONSE_CONTENT*** )

// Create a new HAR with the label "network_traffic"

proxy.newHar('network_traffic')

// Perform login actions

**try** {

WebUI.*navigateToUrl*(login.getValue('url', userrow))
1 Like

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

You can not use Selenium 4 in Katalon Studo v9.x.
Katalon Studio bundles Selenium 3.
You can not change the version of Selenium in Katalon Studio v9.


The following post wrote

Selenium 4 upgrade … That will happen this year.

Just wait half year.

Is there any other way to get the network tab of chrome browser, if yes guidance is required

The Network tab should be to the right of Sources (the house) and other icons at the top when you use the DevTools.

image

I guess you want your Katalon scripts to talk to Chrome browser via “Chrome DevTools Protocol” or “CDP”. Then, see the following resources and try:

Katalon Stduio v9.x (Selenium 3) + CDP integration is a difficult issue, not very much cultivated. I’ve experienced a lot of pitfalls there. I’m no longer interested in it because I found it is far easier to use Selenium 4 unwrapped (without KS) with JUnit/TestNG on Gradle for CDP features. For example,

@saranya.rangarajan

If you just want to have a look at the network traffics exchanged between Browsers and your Web servers, you do not need Selenium 4 (CDP). BrowserMob Proxy will help you. See the following post

I tried to use the sample project provided and included the jar files but still that sample,(BrowserMobProxyInKatalonStudio-1.3.0) project methods are not recognizing even after import , need guidance

If you just want to utilize the BrowserMob Proxy, you do not need to add any external jar files. Every Katalon projects have a file named .classpath. In it you can find the jar of BrowserMob Proxy is included;

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    ....
    <classpathentry kind="lib" 
    path="/Applications/Katalon Studio.app/Contents/Eclipse/configuration/resources/lib/browsermob-core-2.1.5.jar"/>
	....

Additionally if you want to verify the HAR file using Jayway JsonPath or JMESPath, you need to add more jars:

I am sure you haven’t done

$ gradle katalonCopyDependencies

Read the doc for the insturction how to import the jars, please.