Unable to download File From `data:` URL

Please find attached test html file.

Print_PDF.html (27.2 KB)

Step 1: WebUI.openBrowser(‘C:\Users\XXX\Desktop\Print_PDF.html’)
Step 2: Click “Click Here” button
Step 3: Sleep(5000) & Manually Click the browser refresh button, since the PDF is not loading automatically.
Step 4: WebUI.switchToWindowIndex(1)
Step 5: println(WebUI.getUrl())
Step 6 Using Apache Commons IO, download the file from URL

String fileUrl = WebUI.getUrl()
String outputPath = "C:\\downloads\\test.pdf";
FileUtils.copyURLToFile(new URL(fileUrl), new File(outputPath));

Getting Error:

java.net.MalformedURLException: unknown protocol: data

@kazurayam @grylion54 @duyluong @Brandon_Hein

data URIs are not supported.

And don’t hold your breath, it was asked for 4 years ago.

There is nothing wrong with what you are doing – Katalon is at fault.

Moving to Bug Reports

@duyluong @Jass

Thanks @Russ_Thomas … My query is, I just want to download the PDF file from URL. Is there a workaround.

In my AUT, I have url, that starts with blob, I didn’t face any issue with Katalon. I am look for a way to download the PDF file into my local system.

Since the URL Starts with blob or data, when I use Apache Commons IO, I am getting exception as below

java.net.MalformedURLException: unknown protocol: data`

Below are few of the solution, I found on Internet. but I couldn’t succeed. Could you help,

Please have a look at my previous study a year ago:

I believe that there is a bug Katalon Studio’s keywords WebUI.openBrowser(String url) and WebUI.navigateToUrl(String url). Due to the bug, these keywords do not support Data URLs. But a small change can fix it. My research revealed how to.


1 Like

I changed the topic title slightly

“From URL” -> “From data: URL”

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.