Hi,
I have to enable CORS extension by scripting in katalon.
I tried Custom Chrome option but that is not working. Please help.
Hi,
I have to enable CORS extension by scripting in katalon.
I tried Custom Chrome option but that is not working. Please help.
Thanks for the reply.
I tried both the ways .With custom chrome, I am able to add the extension but that is not getting enabled. How to enable it?
Are you able to install the CORS extension in the browser invoked by Katalon (via automation) ?
No, not able to invoke via automation.
1. Firtsly Dowload the CORS .CRX file using the below chrome extension.
2. In Katalon project, create a folder named “ChromeExtension” and paste the CORS.crx as below
3. Create Keyword as mentioned below.
4. Call the Keyword.
CustomKeywords.'desired.ChromeCapabilities.enableExtension'('http://Katalon.com/')
package desired
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.checkpoint.Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable
import org.openqa.selenium.WebDriver as WebDriver
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.configuration.RunConfiguration as RunConfiguration
public class ChromeCapabilities {
@Keyword
public static void enableExtension (String url){
System.setProperty('webdriver.chrome.driver', DriverFactory.chromeDriverPath)
ChromeOptions options = new ChromeOptions()
'Install Chrome extensions - at runtime'
options.addExtensions(new File(RunConfiguration.getProjectDir()+'/ChromeExtension/CORS.crx'))
DesiredCapabilities capabilities = new DesiredCapabilities()
capabilities.setCapability(ChromeOptions.CAPABILITY, options)
'Setting Proxy '
capabilities.setCapability('chrome.switches', Arrays.asList('--proxy-server=127.0.0.1:8888'))
WebDriver driver = new ChromeDriver(capabilities)
DriverFactory.changeWebDriver(driver)
WebUI.maximizeWindow()
WebUI.navigateToUrl(url)
}
}
Tried this , again the extension got added but not enabled by default.