Downloading the files in headless chrome

Hi

I want to download the file in headless chrome.
I’m Using the below code:

HashMap<Object, String> chromePrefs = new HashMap<Object, String>()
chromePrefs.put(“download.default_directory”, RunConfiguration.getProjectDir() + “/Include/TestData/DownloadedFiles”)
chromePrefs.put(“browser.setDownloadBehavior”, “allow”)
RunConfiguration.setWebDriverPreferencesProperty(“prefs”, chromePrefs)

But it’s not working,Is there anyway to accomplish this?

hello,

sorry this not work, need to investigate why
String downloadPath = "C:\\Users\\xxxx\\Desktop\\data\\pdf\\"
Map<String, Object> chromePrefs = new HashMap<String, Object>()
chromePrefs.put("download.default_directory", downloadPath)
chromePrefs.put("download.prompt_for_download", false)
chromePrefs.put("pdfjs.disabled", true);
System.setProperty("webdriver.chrome.driver", DriverFactory.getChromeDriverPath())
ChromeOptions options = new ChromeOptions()
options.addArguments("--headless")
options.setExperimentalOption("prefs", chromePrefs)
WebDriver driver = new ChromeDriver(options)
driver.get("https://docs.oracle.com/javaee/7/JEETT.pdf");
WebUI.delay(10)
System.out.println("Task complete, please go to save folder to see it.");
driver.close()

got it to work in Jidea, now i try to move it into Katalon

ok,

this will work

import org.apache.hc.client5.http.classic.HttpClient
import org.apache.hc.client5.http.classic.methods.HttpPost
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder
import org.apache.hc.core5.http.io.entity.StringEntity
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeDriverService
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.remote.CapabilityType
import org.openqa.selenium.remote.DesiredCapabilities

import com.fasterxml.jackson.databind.ObjectMapper
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

String downloadFilepath = "C:\\Users\\xxxx\\Desktop\\data\\pdf\\"
HashMap<String, Object> chromePreferences = new HashMap<String, Object>();
chromePreferences.put("profile.default_content_settings.popups", 0);
chromePreferences.put("download.prompt_for_download", "false");
chromePreferences.put("download.default_directory", downloadFilepath);
ChromeOptions chromeOptions = new ChromeOptions();
System.setProperty("webdriver.chrome.driver", DriverFactory.getChromeDriverPath())

chromeOptions.addArguments("start-maximized");
chromeOptions.addArguments("disable-infobars");

//HEADLESS CHROME
chromeOptions.addArguments("headless");

chromeOptions.setExperimentalOption("prefs", chromePreferences);
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

ChromeDriverService driverService = ChromeDriverService.createDefaultService();
ChromeDriver driver = new ChromeDriver(driverService, chromeOptions);

Map<String, Object> commandParams = new HashMap<>();
commandParams.put("cmd", "Page.setDownloadBehavior");
Map<String, String> params = new HashMap<>();
params.put("behavior", "allow");
params.put("downloadPath", downloadFilepath);
commandParams.put("params", params);
ObjectMapper objectMapper = new ObjectMapper();
HttpClient httpClient = HttpClientBuilder.create().build();
String command = objectMapper.writeValueAsString(commandParams);
String u = driverService.getUrl().toString() + "/session/" + driver.getSessionId() + "/chromium/send_command";
HttpPost request = new HttpPost(u);
request.addHeader("content-type", "application/json");
request.setEntity(new StringEntity(command));
try {
	httpClient.execute(request);
	driver.get("https://docs.oracle.com/javaee/7/JEETT.pdf");
	WebUI.delay(30)
	System.out.println("Task complete, please go to save folder to see it.");
	driver.close()
} catch (IOException e2) {
	e2.printStackTrace();
}

HI Matt

verified, works fine in my lap top

import org.apache.hc.client5.http.classic.HttpClient
import org.apache.hc.client5.http.classic.methods.HttpPost
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder
import org.apache.hc.core5.http.io.entity.StringEntity
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeDriverService
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.remote.CapabilityType
import org.openqa.selenium.remote.DesiredCapabilities

import com.fasterxml.jackson.databind.ObjectMapper
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

String downloadFilepath = “C:\Users\fitim\Desktop\data\pdf\”
HashMap<String, Object> chromePreferences = new HashMap<String, Object>();
chromePreferences.put(“profile.default_content_settings.popups”, 0);
chromePreferences.put(“download.prompt_for_download”, “false”);
chromePreferences.put(“download.default_directory”, downloadFilepath);
ChromeOptions chromeOptions = new ChromeOptions();
System.setProperty(“webdriver.chrome.driver”, DriverFactory.getChromeDriverPath())

chromeOptions.addArguments(“start-maximized”);
chromeOptions.addArguments(“disable-infobars”);

//HEADLESS CHROME
chromeOptions.addArguments(“headless”);

chromeOptions.setExperimentalOption(“prefs”, chromePreferences);
DesiredCapabilities cap = DesiredCapabilities.chrome();
cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
cap.setCapability(ChromeOptions.CAPABILITY, chromeOptions);

ChromeDriverService driverService = ChromeDriverService.createDefaultService();
ChromeDriver driver = new ChromeDriver(driverService, chromeOptions);

Map<String, Object> commandParams = new HashMap<>();
commandParams.put(“cmd”, “Page.setDownloadBehavior”);
Map<String, String> params = new HashMap<>();
params.put(“behavior”, “allow”);
params.put(“downloadPath”, downloadFilepath);
commandParams.put(“params”, params);
ObjectMapper objectMapper = new ObjectMapper();
HttpClient httpClient = HttpClientBuilder.create().build();
String command = objectMapper.writeValueAsString(commandParams);
String u = driverService.getUrl().toString() + “/session/” + driver.getSessionId() + “/chromium/send_command”;
HttpPost request = new HttpPost(u);
request.addHeader(“content-type”, “application/json”);
request.setEntity(new StringEntity(command));
try {
httpClient.execute(request);
driver.get(“https://docs.oracle.com/javaee/7/JEETT.pdf”);
WebUI.delay(30)
System.out.println(“Task complete, please go to save folder to see it.”);
driver.close()
} catch (IOException e2) {
e2.printStackTrace();
}

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/fitim/KatalonStudio/Katalon_Studio_Windows_64-7.0.10/plugins/ch.qos.logback.classic_1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/fitim/KatalonFromGitHub/KatalonProject/Drivers/imageTxt.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/fitim/KatalonStudio/Katalon_Studio_Windows_64-7.0.10/configuration/plugin/install/31074/1.0.0/katalon-studio-jmeter-integration-plugin-1.0.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
2019-12-06 13:18:37.040 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2019-12-06 13:18:37.175 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/ChromeOptions/ChromeHeadlessDownload
Test Cases/ChromeOptions/ChromeHeadlessDownload
[:]
testCaseContext.getTextCaseId()=Test Cases/ChromeOptions/ChromeHeadlessDownload
2019-12-06 13:18:56.619 DEBUG testcase.ChromeHeadlessDownload - 1: downloadFilepath = “C:\Users\fitim\Desktop\data\pdf”
2019-12-06 13:18:56.656 DEBUG testcase.ChromeHeadlessDownload - 2: chromePreferences = new java.util.HashMap()
2019-12-06 13:18:56.853 DEBUG testcase.ChromeHeadlessDownload - 3: chromePreferences.put(“profile.default_content_settings.popups”, 0)
2019-12-06 13:18:56.861 DEBUG testcase.ChromeHeadlessDownload - 4: chromePreferences.put(“download.prompt_for_download”, “false”)
2019-12-06 13:18:56.912 DEBUG testcase.ChromeHeadlessDownload - 5: chromePreferences.put(“download.default_directory”, downloadFilepath)
2019-12-06 13:18:56.916 DEBUG testcase.ChromeHeadlessDownload - 6: chromeOptions = new org.openqa.selenium.chrome.ChromeOptions()
2019-12-06 13:18:57.736 DEBUG testcase.ChromeHeadlessDownload - 7: System.setProperty(“webdriver.chrome.driver”, getChromeDriverPath())
2019-12-06 13:18:58.325 DEBUG testcase.ChromeHeadlessDownload - 8: chromeOptions.addArguments(“start-maximized”)
2019-12-06 13:18:58.523 DEBUG testcase.ChromeHeadlessDownload - 9: chromeOptions.addArguments(“disable-infobars”)
2019-12-06 13:18:58.679 DEBUG testcase.ChromeHeadlessDownload - 10: chromeOptions.addArguments(“headless”)
2019-12-06 13:18:58.904 DEBUG testcase.ChromeHeadlessDownload - 11: chromeOptions.setExperimentalOption(“prefs”, chromePreferences)
2019-12-06 13:18:59.128 DEBUG testcase.ChromeHeadlessDownload - 12: cap = DesiredCapabilities.chrome()
joulukuuta 06, 2019 1:18:59 IP. org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using new ChromeOptions() is preferred to DesiredCapabilities.chrome()
2019-12-06 13:18:59.328 DEBUG testcase.ChromeHeadlessDownload - 13: cap.setCapability(ACCEPT_SSL_CERTS, true)
2019-12-06 13:18:59.444 DEBUG testcase.ChromeHeadlessDownload - 14: cap.setCapability(CAPABILITY, chromeOptions)
2019-12-06 13:18:59.831 DEBUG testcase.ChromeHeadlessDownload - 15: driverService = ChromeDriverService.createDefaultService()
2019-12-06 13:19:00.981 DEBUG testcase.ChromeHeadlessDownload - 16: driver = new org.openqa.selenium.chrome.ChromeDriver(driverService, chromeOptions)
Starting ChromeDriver 77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865@{#442}) on port 32301
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1575631156.663][WARNING]: This version of ChromeDriver has not been tested with Chrome version 78.
[1575631156.727][WARNING]: This version of ChromeDriver has not been tested with Chrome version 78.
[1575631157.828][WARNING]: This version of ChromeDriver has not been tested with Chrome version 78.
[1575631158.934][WARNING]: This version of ChromeDriver has not been tested with Chrome version 78.
[1575631159.999][WARNING]: This version of ChromeDriver has not been tested with Chrome version 78.
[1575631162.633][WARNING]: Timed out connecting to Chrome, retrying…
joulukuuta 06, 2019 1:19:25 IP. org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
2019-12-06 13:19:25.472 DEBUG testcase.ChromeHeadlessDownload - 17: commandParams = new java.util.HashMap()
2019-12-06 13:19:25.518 DEBUG testcase.ChromeHeadlessDownload - 18: commandParams.put(“cmd”, “Page.setDownloadBehavior”)
2019-12-06 13:19:25.595 DEBUG testcase.ChromeHeadlessDownload - 19: params = new java.util.HashMap()
2019-12-06 13:19:25.675 DEBUG testcase.ChromeHeadlessDownload - 20: params.put(“behavior”, “allow”)
2019-12-06 13:19:25.690 DEBUG testcase.ChromeHeadlessDownload - 21: params.put(“downloadPath”, downloadFilepath)
2019-12-06 13:19:25.702 DEBUG testcase.ChromeHeadlessDownload - 22: commandParams.put(“params”, params)
2019-12-06 13:19:25.995 DEBUG testcase.ChromeHeadlessDownload - 23: objectMapper = new com.fasterxml.jackson.databind.ObjectMapper()
2019-12-06 13:19:29.629 DEBUG testcase.ChromeHeadlessDownload - 24: httpClient = create().build()
2019-12-06 13:19:31.067 DEBUG testcase.ChromeHeadlessDownload - 25: command = objectMapper.writeValueAsString(commandParams)
2019-12-06 13:19:31.328 DEBUG testcase.ChromeHeadlessDownload - 26: u = getUrl().toString() + “/session/” + driver.getSessionId() + “/chromium/send_command”
2019-12-06 13:19:31.515 DEBUG testcase.ChromeHeadlessDownload - 27: request = new org.apache.hc.client5.http.classic.methods.HttpPost(u)
2019-12-06 13:19:32.512 DEBUG testcase.ChromeHeadlessDownload - 28: request.addHeader(“content-type”, “application/json”)
2019-12-06 13:19:32.652 DEBUG testcase.ChromeHeadlessDownload - 29: request.setEntity(new org.apache.hc.core5.http.io.entity.StringEntity(command))
2019-12-06 13:19:33.832 DEBUG testcase.ChromeHeadlessDownload - 30: try
2019-12-06 13:19:33.840 DEBUG testcase.ChromeHeadlessDownload - 1: httpClient.execute(request)
2019-12-06 13:19:34.794 DEBUG testcase.ChromeHeadlessDownload - 2: driver.get(“https://docs.oracle.com/javaee/7/JEETT.pdf”)
2019-12-06 13:19:38.694 DEBUG testcase.ChromeHeadlessDownload - 3: delay(30)
2019-12-06 13:20:09.305 DEBUG testcase.ChromeHeadlessDownload - 4: out.println(“Task complete, please go to save folder to see it.”)
Task complete, please go to save folder to see it.
2019-12-06 13:20:09.534 DEBUG testcase.ChromeHeadlessDownload - 5: driver.close()
2019-12-06 13:20:10.439 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/ChromeOptions/ChromeHeadlessDownload

what kind of issues you have?

Thank you for checking! Luckily I was able to resolve this due to an issue with escaped characters in my file path. It was working, just not saving to the location I expected.

:white_check_mark: Confirmed that your driver config works with headless file downloads.

Hi. here is the issue I’m having while trying to run it:

Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS:
2020-08-07 08:05:07.317 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2020-08-07 08:05:07.321 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/Misc/TC_CH_Download
Test Cases/Misc/TC_CH_Download
[:]
2020-08-07 08:05:07.860 INFO c.k.k.core.webui.driver.DriverFactory - Starting ‘Chrome’ driver
Aug 07, 2020 8:05:07 AM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using new ChromeOptions() is preferred to DesiredCapabilities.chrome()
2020-08-07 08:05:07.918 INFO c.k.k.c.w.util.WebDriverPropertyUtil - User set preference: [‘args’, ‘[–start-maximized]’]
2020-08-07 08:05:07.955 INFO c.k.k.core.webui.driver.DriverFactory - Action delay is set to 0 milliseconds
Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 36205
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1596801910.578][WARNING]: This version of ChromeDriver has not been tested with Chrome version 84.
Aug 07, 2020 8:05:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
2020-08-07 08:05:12.691 INFO c.k.k.core.webui.driver.DriverFactory - sessionId = 20692e18164871106606aebc8abd3550
2020-08-07 08:05:12.707 INFO c.k.k.core.webui.driver.DriverFactory - browser = Chrome 84.0.4147.105
2020-08-07 08:05:12.708 INFO c.k.k.core.webui.driver.DriverFactory - platform = Windows 10
2020-08-07 08:05:12.709 INFO c.k.k.core.webui.driver.DriverFactory - seleniumVersion = 3.141.59
2020-08-07 08:05:12.710 INFO c.k.k.core.webui.driver.DriverFactory - proxyInformation = ProxyInformation { proxyOption=NO_PROXY, proxyServerType=HTTP, username=, password=********, proxyServerAddress=, proxyServerPort=0, executionList="", isApplyToDesiredCapabilities=true }
2020-08-07 08:05:12.957 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Misc/TC_CH_Download FAILED.
Reason:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
file:/C:/Users/Admin/Katalon%20Studio/MyProject1/Scripts/Misc/TC_CH_Download/Script1596801211389.groovy: 22: unable to resolve class org.apache.hc.client5.http.classic.methods.HttpPost
@ line 22, column 1.
import org.apache.hc.client5.http.classic.methods.HttpPost
^

file:/C:/Users/Admin/Katalon%20Studio/MyProject1/Scripts/Misc/TC_CH_Download/Script1596801211389.groovy: 24: unable to resolve class org.apache.hc.core5.http.io.entity.StringEntity
@ line 24, column 1.
import org.apache.hc.core5.http.io.entity.StringEntity
^

file:/C:/Users/Admin/Katalon%20Studio/MyProject1/Scripts/Misc/TC_CH_Download/Script1596801211389.groovy: 21: unable to resolve class org.apache.hc.client5.http.classic.HttpClient
@ line 21, column 1.
import org.apache.hc.client5.http.classic.HttpClient
^

file:/C:/Users/Admin/Katalon%20Studio/MyProject1/Scripts/Misc/TC_CH_Download/Script1596801211389.groovy: 23: unable to resolve class org.apache.hc.client5.http.impl.classic.HttpClientBuilder
@ line 23, column 1.
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder
^

4 errors

at com.kms.katalon.core.main.ScriptEngine.getScript(ScriptEngine.java:199)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1596801901203.run(TempTestCase1596801901203.groovy:25)

Test Cases/Misc/TC_CH_Download
ERROR
2020-08-07 08:05:12.982 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/Misc/TC_CH_Download

Hi,

are you added all needed .jar’s to your project Drivers folder?
e.g
http://www.java2s.com/Code/Jar/a/Downloadapachehttpcomponentshttpcorejar.htm

Hi Timo_Kuisma1, I downloaded apache-httpcomponents-httpcore.jar imported it in Katalon studio

and got the following while trying to run the code above:

Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS:
2020-08-09 12:06:02.666 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2020-08-09 12:06:02.670 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/Misc/TC_CH_Download_1
Test Cases/Misc/TC_CH_Download_1
[:]
2020-08-09 12:06:03.145 INFO c.k.k.core.webui.driver.DriverFactory - Starting ‘Chrome’ driver
Aug 09, 2020 12:06:03 PM org.openqa.selenium.remote.DesiredCapabilities chrome
INFO: Using new ChromeOptions() is preferred to DesiredCapabilities.chrome()
2020-08-09 12:06:03.165 INFO c.k.k.c.w.util.WebDriverPropertyUtil - User set preference: [‘args’, ‘[–start-maximized]’]
2020-08-09 12:06:03.192 INFO c.k.k.core.webui.driver.DriverFactory - Action delay is set to 0 milliseconds
Starting ChromeDriver 83.0.4103.39 (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 45575
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1596989165.322][WARNING]: This version of ChromeDriver has not been tested with Chrome version 84.
Aug 09, 2020 12:06:07 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: W3C
2020-08-09 12:06:07.440 INFO c.k.k.core.webui.driver.DriverFactory - sessionId = e8599b9052b740c38e370f3c227c48c3
2020-08-09 12:06:07.457 INFO c.k.k.core.webui.driver.DriverFactory - browser = Chrome 84.0.4147.105
2020-08-09 12:06:07.458 INFO c.k.k.core.webui.driver.DriverFactory - platform = Windows 10
2020-08-09 12:06:07.458 INFO c.k.k.core.webui.driver.DriverFactory - seleniumVersion = 3.141.59
2020-08-09 12:06:07.459 INFO c.k.k.core.webui.driver.DriverFactory - proxyInformation = ProxyInformation { proxyOption=NO_PROXY, proxyServerType=HTTP, username=, password=********, proxyServerAddress=, proxyServerPort=0, executionList="", isApplyToDesiredCapabilities=true }
2020-08-09 12:06:07.715 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Misc/TC_CH_Download_1 FAILED.
Reason:
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
file:/C:/Users/Admin/Katalon%20Studio/MyProject1/Scripts/Misc/TC_CH_Download_1/Script1596803315209.groovy: 22: unable to resolve class org.apache.hc.client5.http.classic.methods.HttpPost
@ line 22, column 1.
import org.apache.hc.client5.http.classic.methods.HttpPost
^

file:/C:/Users/Admin/Katalon%20Studio/MyProject1/Scripts/Misc/TC_CH_Download_1/Script1596803315209.groovy: 24: unable to resolve class org.apache.hc.core5.http.io.entity.StringEntity
@ line 24, column 1.
import org.apache.hc.core5.http.io.entity.StringEntity
^

file:/C:/Users/Admin/Katalon%20Studio/MyProject1/Scripts/Misc/TC_CH_Download_1/Script1596803315209.groovy: 21: unable to resolve class org.apache.hc.client5.http.classic.HttpClient
@ line 21, column 1.
import org.apache.hc.client5.http.classic.HttpClient
^

file:/C:/Users/Admin/Katalon%20Studio/MyProject1/Scripts/Misc/TC_CH_Download_1/Script1596803315209.groovy: 23: unable to resolve class org.apache.hc.client5.http.impl.classic.HttpClientBuilder
@ line 23, column 1.
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder
^

file:/C:/Users/Admin/Katalon%20Studio/MyProject1/Scripts/Misc/TC_CH_Download_1/Script1596803315209.groovy: 68: unable to resolve class ObjectMapper
@ line 68, column 14.
ObjectMapper objectMapper = new ObjectMapper();
^

file:/C:/Users/Admin/Katalon%20Studio/MyProject1/Scripts/Misc/TC_CH_Download_1/Script1596803315209.groovy: 68: unable to resolve class ObjectMapper
@ line 68, column 29.
ObjectMapper objectMapper = new ObjectMapper();
^

6 errors

at com.kms.katalon.core.main.ScriptEngine.getScript(ScriptEngine.java:199)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1596989160276.run(TempTestCase1596989160276.groovy:25)

Test Cases/Misc/TC_CH_Download_1
ERROR
2020-08-09 12:06:07.740 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/Misc/TC_CH_Download_1

By the way, Timo_Kuisma1

I cannot see these (from your source):

import org.apache.hc.client5.http.classic.HttpClient
import org.apache.hc.client5.http.classic.methods.HttpPost
import org.apache.hc.client5.http.impl.classic.HttpClientBuilder
import org.apache.hc.core5.http.io.entity.StringEntity

among these (from your link):

Search

Download apache-httpcomponents-httpcore.jar : apache httpcomponents « a « Jar File Download

  1. Jar File Download
  2. a
  3. apache httpcomponents

Download apache-httpcomponents-httpcore.jar

apache-httpcomponents/apache-httpcomponents-httpcore.jar.zip( 160 k)

The download jar file contains the following class files or Java source files.

META-INF/LICENSE.txt META-INF/MANIFEST.MF META-INF/NOTICE.txt META-INF/maven/org.apache.httpcomponents/httpcore/pom.properties META-INF/maven/org.apache.httpcomponents/httpcore/pom.xml org.apache.http.ConnectionClosedException.class org.apache.http.ConnectionReuseStrategy.class org.apache.http.FormattedHeader.class org.apache.http.Header.class org.apache.http.HeaderElement.class org.apache.http.HeaderElementIterator.class org.apache.http.HeaderIterator.class org.apache.http.HttpClientConnection.class org.apache.http.HttpConnection.class org.apache.http.HttpConnectionMetrics.class org.apache.http.HttpEntity.class org.apache.http.HttpEntityEnclosingRequest.class org.apache.http.HttpException.class org.apache.http.HttpHeaders.class org.apache.http.HttpHost.class org.apache.http.HttpInetConnection.class org.apache.http.HttpMessage.class org.apache.http.HttpRequest.class org.apache.http.HttpRequestFactory.class org.apache.http.HttpRequestInterceptor.class org.apache.http.HttpResponse.class org.apache.http.HttpResponseFactory.class org.apache.http.HttpResponseInterceptor.class org.apache.http.HttpServerConnection.class org.apache.http.HttpStatus.class org.apache.http.HttpVersion.class org.apache.http.MalformedChunkCodingException.class org.apache.http.MethodNotSupportedException.class org.apache.http.NameValuePair.class org.apache.http.NoHttpResponseException.class org.apache.http.ParseException.class org.apache.http.ProtocolException.class org.apache.http.ProtocolVersion.class org.apache.http.ReasonPhraseCatalog.class org.apache.http.RequestLine.class org.apache.http.StatusLine.class org.apache.http.TokenIterator.class org.apache.http.TruncatedChunkException.class org.apache.http.UnsupportedHttpVersionException.class org.apache.http.entity.AbstractHttpEntity.class org.apache.http.entity.BasicHttpEntity.class org.apache.http.entity.BufferedHttpEntity.class org.apache.http.entity.ByteArrayEntity.class org.apache.http.entity.ContentLengthStrategy.class org.apache.http.entity.ContentProducer.class org.apache.http.entity.EntityTemplate.class org.apache.http.entity.FileEntity.class org.apache.http.entity.HttpEntityWrapper.class org.apache.http.entity.InputStreamEntity.class org.apache.http.entity.SerializableEntity.class org.apache.http.entity.StringEntity.class org.apache.http.impl.AbstractHttpClientConnection.class org.apache.http.impl.AbstractHttpServerConnection.class org.apache.http.impl.DefaultConnectionReuseStrategy.class org.apache.http.impl.DefaultHttpClientConnection.class org.apache.http.impl.DefaultHttpRequestFactory.class org.apache.http.impl.DefaultHttpResponseFactory.class org.apache.http.impl.DefaultHttpServerConnection.class org.apache.http.impl.EnglishReasonPhraseCatalog.class org.apache.http.impl.HttpConnectionMetricsImpl.class org.apache.http.impl.NoConnectionReuseStrategy.class org.apache.http.impl.SocketHttpClientConnection.class org.apache.http.impl.SocketHttpServerConnection.class org.apache.http.impl.entity.EntityDeserializer.class org.apache.http.impl.entity.EntitySerializer.class org.apache.http.impl.entity.LaxContentLengthStrategy.class org.apache.http.impl.entity.StrictContentLengthStrategy.class org.apache.http.impl.io.AbstractMessageParser.class org.apache.http.impl.io.AbstractMessageWriter.class org.apache.http.impl.io.AbstractSessionInputBuffer.class org.apache.http.impl.io.AbstractSessionOutputBuffer.class org.apache.http.impl.io.ChunkedInputStream.class org.apache.http.impl.io.ChunkedOutputStream.class org.apache.http.impl.io.ContentLengthInputStream.class org.apache.http.impl.io.ContentLengthOutputStream.class org.apache.http.impl.io.HttpRequestParser.class org.apache.http.impl.io.HttpRequestWriter.class org.apache.http.impl.io.HttpResponseParser.class org.apache.http.impl.io.HttpResponseWriter.class org.apache.http.impl.io.HttpTransportMetricsImpl.class org.apache.http.impl.io.IdentityInputStream.class org.apache.http.impl.io.IdentityOutputStream.class org.apache.http.impl.io.SocketInputBuffer.class org.apache.http.impl.io.SocketOutputBuffer.class org.apache.http.io.BufferInfo.class org.apache.http.io.EofSensor.class org.apache.http.io.HttpMessageParser.class org.apache.http.io.HttpMessageWriter.class org.apache.http.io.HttpTransportMetrics.class org.apache.http.io.SessionInputBuffer.class org.apache.http.io.SessionOutputBuffer.class org.apache.http.message.AbstractHttpMessage.class org.apache.http.message.BasicHeader.class org.apache.http.message.BasicHeaderElement.class org.apache.http.message.BasicHeaderElementIterator.class org.apache.http.message.BasicHeaderIterator.class org.apache.http.message.BasicHeaderValueFormatter.class org.apache.http.message.BasicHeaderValueParser.class org.apache.http.message.BasicHttpEntityEnclosingRequest.class org.apache.http.message.BasicHttpRequest.class org.apache.http.message.BasicHttpResponse.class org.apache.http.message.BasicLineFormatter.class org.apache.http.message.BasicLineParser.class org.apache.http.message.BasicListHeaderIterator.class org.apache.http.message.BasicNameValuePair.class org.apache.http.message.BasicRequestLine.class org.apache.http.message.BasicStatusLine.class org.apache.http.message.BasicTokenIterator.class org.apache.http.message.BufferedHeader.class org.apache.http.message.HeaderGroup.class org.apache.http.message.HeaderValueFormatter.class org.apache.http.message.HeaderValueParser.class org.apache.http.message.LineFormatter.class org.apache.http.message.LineParser.class org.apache.http.message.ParserCursor.class org.apache.http.params.AbstractHttpParams.class org.apache.http.params.BasicHttpParams.class org.apache.http.params.CoreConnectionPNames.class org.apache.http.params.CoreProtocolPNames.class org.apache.http.params.DefaultedHttpParams.class org.apache.http.params.HttpAbstractParamBean.class org.apache.http.params.HttpConnectionParamBean.class org.apache.http.params.HttpConnectionParams.class org.apache.http.params.HttpParams.class org.apache.http.params.HttpProtocolParamBean.class org.apache.http.params.HttpProtocolParams.class org.apache.http.params.SyncBasicHttpParams.class org.apache.http.protocol.BasicHttpContext.class org.apache.http.protocol.BasicHttpProcessor.class org.apache.http.protocol.DefaultedHttpContext.class org.apache.http.protocol.ExecutionContext.class org.apache.http.protocol.HTTP.class org.apache.http.protocol.HttpContext.class org.apache.http.protocol.HttpDateGenerator.class org.apache.http.protocol.HttpExpectationVerifier.class org.apache.http.protocol.HttpProcessor.class org.apache.http.protocol.HttpRequestExecutor.class org.apache.http.protocol.HttpRequestHandler.class org.apache.http.protocol.HttpRequestHandlerRegistry.class org.apache.http.protocol.HttpRequestHandlerResolver.class org.apache.http.protocol.HttpRequestInterceptorList.class org.apache.http.protocol.HttpResponseInterceptorList.class org.apache.http.protocol.HttpService.class org.apache.http.protocol.ImmutableHttpProcessor.class org.apache.http.protocol.RequestConnControl.class org.apache.http.protocol.RequestContent.class org.apache.http.protocol.RequestDate.class org.apache.http.protocol.RequestExpectContinue.class org.apache.http.protocol.RequestTargetHost.class org.apache.http.protocol.RequestUserAgent.class org.apache.http.protocol.ResponseConnControl.class org.apache.http.protocol.ResponseContent.class org.apache.http.protocol.ResponseDate.class org.apache.http.protocol.ResponseServer.class org.apache.http.protocol.SyncBasicHttpContext.class org.apache.http.protocol.UriPatternMatcher.class org.apache.http.util.ByteArrayBuffer.class org.apache.http.util.CharArrayBuffer.class org.apache.http.util.EncodingUtils.class org.apache.http.util.EntityUtils.class org.apache.http.util.ExceptionUtils.class org.apache.http.util.LangUtils.class org.apache.http.util.VersionInfo.class org/apache/http/version.properties

Related examples in the same category

java2s.com | © Demo Source and Support. All rights reserved.