How to Modify Request Headers while using chrome for running testcases

Hi, I need to set request headers in the chrome, since my application gets authenticated through header. I’m able to capture test case by using active browser(chrome) using some extension to modify header but when i run the TC it opens a new browser that doesn’t have that extension. so is there any way to modify request header through katalon. Thanks

Hi Shamuga,

If you want to install extension directly into new browser started by Katalon Studio, then you need to wrap the current chromedriver first following with this guide, e.g is the way to install the UNPACKED extension. With this example, you can install your extension there:

import org.openqa.selenium.chrome.ChromeDriver as ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions as ChromeOptions
import org.openqa.selenium.remote.DesiredCapabilities as DesiredCapabilities
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
ChromeOptions options = new ChromeOptions()
DesiredCapabilities capabilities = new DesiredCapabilities()
options.addArguments("load-extension=/path/to/extension")
capabilities.setCapability(ChromeOptions.CAPABILITY, options)
//Path to chromedriver, e.g on MacOSSystem.setProperty("webdriver.chrome.driver", "/Applications/Katalon Studio.app/Contents/Eclipse/configuration/resources/drivers/chromedriver_mac/chromedriver");
ChromeDriver driver = new ChromeDriver(capabilities)
DriverFactory.changeWebDriver(driver)
//Call WebUI keywords hereWebUI.navigateToUrl('demoaut.katalon.com')

Vinh Nguyen . Thanks a lot :slight_smile: . It worked perfectly.

Vinh Nguyen said:

Hi Shamuga,

If you want to install extension directly into new browser started by Katalon Studio, then you need to wrap the current chromedriver first following with this guide, e.g is the way to install the UNPACKED extension. With this example, you can install your extension there:

import org.openqa.selenium.chrome.ChromeDriver as ChromeDriver

import org.openqa.selenium.chrome.ChromeOptions as ChromeOptions
import org.openqa.selenium.remote.DesiredCapabilities as DesiredCapabilities
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
ChromeOptions options = new ChromeOptions()
DesiredCapabilities capabilities = new DesiredCapabilities()
options.addArguments(“load-extension=/path/to/extension”)
capabilities.setCapability(ChromeOptions.CAPABILITY, options)
//Path to chromedriver, e.g on MacOSSystem.setProperty(“webdriver.chrome.driver”, “/Applications/Katalon Studio.app/Contents/Eclipse/configuration/resources/drivers/chromedriver_mac/chromedriver”);
ChromeDriver driver = new ChromeDriver(capabilities)
DriverFactory.changeWebDriver(driver)
//Call WebUI keywords hereWebUI.navigateToUrl(‘demoaut.katalon.com’)


  

@Vinh Nguyen,

Thanks for share the info.

Now the ModHeader extension is available when opening the chrome browser, but the saved header value is lost, is there a way to set the header values in ModHeader automatically?

3 Likes

@layton.luo did you find a solution?

2 Likes

Hello
I also tried to solve the problem with a plugin. I could also load the plugin, but how can modify the header afterwards?
Greeting

1 Like

Any solutions?

Any solutions?

Also looking for a solution that doesnt require adding browser addons as that isnt really a solution.