Unable to Install chrome extension at runtime

The code below isn’t installing the Chrome extension at runtime in Katalon version 10.3.2. However, it executes successfully without any errors — the Chrome browser opens and navigates to the URL as expected.

Could someone please help me figure out why the extension isn’t being installed?

Note: The Chrome browser version is 142.0.7444.60.

@kazurayam

import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions

@Keyword
public static void installExtensionRuntim(String url){

	// Set ChromeDriver path
	System.setProperty('webdriver.chrome.driver', "\\configuration\\resources\\drivers\\chromedriver_win32\\chromedriver.exe")

	// Set Chrome options
	ChromeOptions options = new ChromeOptions()
	println RunConfiguration.getProjectDir()		
	

	// Add Chrome extension (SelectorsHub)
	options.addExtensions(new File(RunConfiguration.getProjectDir() + '/ChromeExtension/SelectorsHub.crx'))

	// You can also add more custom arguments if needed
	options.addArguments('--start-maximized')

	// Initialize ChromeDriver with options (NOT DesiredCapabilities)
	WebDriver driver = new ChromeDriver(options)

	// Replace Katalon's default driver
	DriverFactory.changeWebDriver(driver)

	// Navigate to target URL
	WebUI.navigateToUrl(url)
}
2 Likes

I am not experienced about the issue, but at a glance I noticed an error:

This path will be regarded as an absolute path which starts with C:\\configuration\\resources..... It wont be there in fact.

You need to specifiy the path correctly:

"${KATALON_STUDIO_INSTALLATION_FOLDER}\\configuration\\resources\\drivers\\chromedriver_win32\\chromedriver.exe"

KATALON_STUDIO_INSTALLATION_FOLDER stands for the absolute path of the folder where you installed Katalon Studio. For example, in my case on mac,

def KATALON_STUDIO_INSTALLATION_FOLDER  = '/Application/Katalon Studio.app/Contents/Eclipse'
1 Like

issue resolved ??

Thanks for your prompt reply! Sorry for the confusion regarding the Chrome driver path. In my code, I’ve included the absolute path to the Chromedriver, but the Chrome extension still isn’t being installed.

1 Like

No the issue is not resolved.

1 Like

hi @discover.selenium

newer Chrome versions might have strict extension policies. try to unpacking the extension first, then load it

options.addArguments("--load-extension=" + RunConfiguration.getProjectDir() + "/ChromeExtension/SelectorsHub")
1 Like