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));
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.
Example: the following should work:
But KS (java.nio) issues the following error:
Unable to navigate to ‘data:text/html;charset=utf-8,
Katalon’ (Root cause: java.nio.file.InvalidPathException: Illegal char <:> at index 4: data:text/html;charset=utf-8,Katalon)
which is silly – a colon is certainly NOT an illegal character when part of a Scheme, otherwise http:, https: etc should fail also… goodbye the interwebz.
There is nothing wrong with what you are doing – Katalon is at fault.
@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 have published a GitHub repository.
Problem to solve
In the Katalon Forum, there are a few posts that ask Katalon Studio to support Data URL.
URLs supplied to Katalon APIs MUST support data URIs
Katalon does not support Data URLs (rfc2397)
I want to write a Test Case script like this:
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
Here the code fragment " data:text/html,<h1>Hello, world!</h1> " is cal…
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.
I changed the topic title slightly
“From URL” -> “From data: URL”
March 2, 2023, 5:18am
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.