Hi Community members, ![]()
Today, we are back with another article to help you add various Chrome extensions and integrating them with Katalon Studio using Selenium scripts to streamline your testing experiences with Studio. Read more below ![]()
When it comes to testing web applications with Chrome extensions using Selenium and Katalon Studio, the traditional approach involves setting up a custom Chrome profile with the required extensions. However, there are scenarios, like working in restricted environments, where using custom profiles may not be possible.
In such cases, Selenium can be leveraged to dynamically add Chrome extensions directly within your test scripts. You can use Selenium to add the extension at the beginning of your test scripts (before the
driver.getmethod) by usingoptions.addExtensions(new File("/path/to/extension.crx"));
Solution
To do that, first, you will need to create a .crx of your extension by following these steps:
-
Go to
chrome://extensions/ -
Turn on developer mode
-
Select the desired extension details
-
Copy extension ID (such as eningockdidmgiojffjmkdblpjocbhgh)
-
Open the Chrome extensions folder on your local machine:
- For Windows:
C:\Users\Administrator\AppData\Local\Google\Chrome\UserData\Default\Extensions - For Mac:
/Users/<<username>>/Library/Application Support/Google/Chrome/Default/Extensions
- For Windows:
-
Search the extension folder by the ID value you have copied
-
Copy this folder to the Desktop
-
Back to this Chrome Extensions on the web, select Pack Extension and browser to this Desktop folder
Then, You will get a .crx file created in the folder.
To create some Selenium scripts to add this extension, please see my custom scripts below:
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.remote.DesiredCapabilities
import com.kms.katalon.core.webui.driver.DriverFactory
import org.openqa.selenium.WebDriver
// Copy the path to Chromedriver
String pathToChromeDriver = '/Applications/Katalon Studio 8.6.0.app/Contents/Eclipse/configuration/resources/drivers/chromedriver_mac/chromedriver'
System.setProperty('webdriver.chrome.driver', pathToChromeDriver)
//This class is used for customizing the Chrome session
ChromeOptions options = new ChromeOptions()
options.addExtensions(new File("/Users/thi.thai/Desktop/eningockdidmgiojffjmkdblpjocbhgh/4.1.1_0.crx"))
DesiredCapabilities caps = new DesiredCapabilities()
caps.setCapability(ChromeOptions.CAPABILITY, options)
WebDriver driver = new ChromeDriver(caps)
DriverFactory.changeWebDriver(driver)
//Maximize window
driver.manage().window().maximize()
WebUI.navigateToUrl("https://google.com")
After that, you can execute the test with any browser, and it should then be added to your extensions.
Reference
If you find this article helpful, then donβt forget to give us a big like
or a heart
. That would mean a lot for us to continue sharing with you these KShare articles!
You can also share this article by following the instructions in the comment below. ![]()


