# Katalon does not support Data URLs (rfc2397)

**URL:** <https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672>\
**Category:** Bug Report\
**Tags:** bugs-report, katalon-studio\
**Created:** [April 23, 2019, 1:35pm UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672 "2019-04-23T13:35:09Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [April 23, 2019, 1:35pm UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/1 "2019-04-23T13:35:09Z")

</div>

# Katalon Should Support All URL Schemes and Protocols

> I thought hard about whether to post this as a bug or as a suggestion. The problem with “suggestion” is it implies it can be declined or even ignored. And since this is a failing in terms of Katalon’s ability to automate a browser, it seems valid to call it what it is: **a bug**.

Data URLs are a thing. Katalon does not support them. Katalon _should_ support them.

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/0/016f19a0e6adda2bfde4742d199a34ce09ec2418.png)

Example:

```auto
WebUI.navigateToUrl('data:text/html;charset=utf-8,<div>Katalon</div>')

```

Which _should_ result in this being produced in the browser:

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/c/cf3fa4014f3567b7a834fc7c5293b2431da8d2a5.png)

But Katalon stops with an error and note that the failure occurs in Java/Groovy code, not the webdriver:

```auto
Unable to navigate to 'data:text/html;charset=utf-8,<div>Katalon</div>' 
(Root cause: com.kms.katalon.core.exception.StepFailedException: 
Unable to navigate to 'data:text/html;charset=utf-8,<div>Katalon</div>'
--snip--
at TempTestCase1556024744947.run(TempTestCase1556024744947.groovy:21)
Caused by: java.nio.file.InvalidPathException: 
Illegal char <:> at index 4: data:text/html;charset=utf-8,<div>Katalon</div>

```

### Supporting Information:

> **[data: URLs - URIs | MDN](https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data)**
>
> Data URLs, URLs prefixed with the data: scheme, allow content creators to embed small files inline in documents. They were formerly known as "data URIs" until that name was retired by the WHATWG.

> **[RFC 2397: The "data" URL scheme](https://datatracker.ietf.org/doc/html/rfc2397)**
>
> A new URL scheme, "data", is defined. It allows inclusion of small data items as "immediate" data, as if it had been included externally. \[STANDARDS-TRACK\]

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/katalon/original/3X/d/5/d55596ab02785a255798e87ede769734747b30c4.svg) [@system](https://forum.katalon.com/u/system)\
**Post date:** [April 19, 2020, 6:46pm UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/2 "2020-04-19T18:46:11Z")

</div>

Automatically bumped on April 19, 2020, 6:46pm UTC



---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [April 19, 2020, 11:43pm UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/3 "2020-04-19T23:43:18Z")

</div>

@ThanhTo @duyluong Any traction on this?

---

<div class="post-metadata">

**Author:** ![ThanhTo](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/thanhto/32/697_2.png) [@ThanhTo](https://forum.katalon.com/u/ThanhTo)\
**Post date:** [April 20, 2020, 3:19am UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/4 "2020-04-20T03:19:49Z")

</div>

@Russ_Thomas

Sorry I wasn’t aware of this. Could you elaborate more on the use case of Data URLs ? Highly appreciate if you can pour the details in a ticket:

> **[katalon-studio/katalon-studio](https://github.com/katalon-studio/katalon-studio/issues)**
>
> Contribute to katalon-studio/katalon-studio development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [April 20, 2020, 1:52pm UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/5 "2020-04-20T13:52:48Z")

</div>

That’s hard to answer properly - they can be used for many things. Perhaps most commonly images? But as my little demo shows, they’re fully supported directly in the address bar, too.

There’s more discussion below (not quite sure why we ended up with two reports 😊)

> [@URLs supplied to Katalon APIs MUST support data URIs](http://forum.katalon.com/t/urls-supplied-to-katalon-apis-must-support-data-uris/12203):
>
> Example: the following should work: WebUI.navigateToUrl('data:text/html;charset=utf-8,\<div\>Katalon\</div\>') 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. [https:…](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics%5C_of%5C_HTTP/Data%5C_URIs#Browser%5C_compatibility)

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [April 20, 2020, 3:41pm UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/6 "2020-04-20T15:41:20Z")

</div>

I now recall my original intent.

> Side Note: I would fully understand if the devs decide this is too niche a requirement. But the fact remains, Data URIs are legal and Katalon fails to support them in any form.

Using `callTestCase()`, I developed something called a **Super Test Case** or **Suite-Test-Case** (STCs). They are a means to run something like a suite without some of the baggage of suites (mostly avoiding conventional reporting) plus provide a way to control the context around all the member Test Cases (you can specify things like `before-tc` to ensure a preparatory TC is executed before a given TC.

> STCs are of course meant for Test development purposes and perhaps less useful for published suite-type purposes.

Here’s a screenshot of some of my notes on the topic.

 ![image](https://europe1.discourse-cdn.com/katalon/original/2X/e/e6948f482ff2db5abc92fc481d68bf74e1c4e23f.png)

To complete the story, I wanted to output the STC report directly in the browser. A Groovy string would be used to store the HTML for the report and passed to the browser as a data URI.

Because Data URIs are not supported, I had to write the string to a file and then navigate to it using a `file:` schema. That works but it’s a messier way to do such a simple thing. (Plus the files need to be cleaned up at some point.)

So, again, you might consider that to be a niche requirement but since it’s useful for a TC developer, there’s every chance it could be re-purposed as a plugin (I’d probably pass it over to @kazurayam to do that - I’m not an Eclipse/Java guy as we all know 😊)

---

<div class="post-metadata">

**Author:** ![system](https://europe1.discourse-cdn.com/katalon/original/3X/d/5/d55596ab02785a255798e87ede769734747b30c4.svg) [@system](https://forum.katalon.com/u/system)\
**Post date:** [April 18, 2021, 4:47pm UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/7 "2021-04-18T16:47:39Z")

</div>

Automatically bumped on April 18, 2021, 4:47pm UTC



---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [April 19, 2021, 7:51am UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/8 "2021-04-19T07:51:57Z")

</div>

@Russ_Thomas

> [@Russ\_Thomas](#):
>
> I’d probably pass it over to @kazurayam to do that

Do you still want me to do that?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [April 19, 2021, 8:00am UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/9 "2021-04-19T08:00:38Z")

</div>

One idea:

```auto
import some.package.DataURL

WebUI.navigateToUrl(DataURL.get('data:text/html;charset=utf-8,<div>Katalon</div>').toFileURL().toString())

```

The `toFileURL` keyword method of `DataURL` class will do “write the to a temporary file and return an instance of java.net.URL with `file:` schema which points to the temporary file”.

Are you satisfied if the keyword supports only the MIME TYPE `text/html`?Do you require other MIME TYPES such as `image/png` and `video/mp4`?

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [April 19, 2021, 1:01pm UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/10 "2021-04-19T13:01:11Z")

</div>

Does that bump into this ?

> [@Russ\_Thomas](#):
>
> I had to write the string to a file and then navigate to it using a `file:` schema. That works but it’s a messier way to do such a simple thing. (Plus the files need to be cleaned up at some point.)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [April 19, 2021, 1:13pm UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/11 "2021-04-19T13:13:43Z")

</div>

Yes.  
DataURl class would be responsible for creating and cleaning temp files.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [April 19, 2021, 1:26pm UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/12 "2021-04-19T13:26:31Z")

</div>

> [@kazurayam](#):
>
> Are you satisfied if the keyword supports only the MIME TYPE `text/html` ?Do you require other MIME TYPES such as `image/png` and `video/mp4` ?

As a test, yes. However, if the package has a class _called_ dataURI, it should support all possible dataURIs - don’t you think?

As an initial step, I suppose you could write:

> some.package.dataURI.text\_html

and in future add…

> some.package.dataURI.text\_plain  
> some.package.dataURI.image\_png

etc. Make sense?

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [April 22, 2021, 11:09am UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/13 "2021-04-22T11:09:44Z")

</div>

I have a new finding on Data URI support in Katalon Studio. I made 2 TestCase scripts.

## Test Cases/research/1\_webui\_navigateToUrl\_data`

```auto
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

WebUI.openBrowser('')
WebUI.navigateToUrl("data:text/html,<h1>Hello, world!</h1>")

```

The 1st script opened a browser, navigated to the URL:

- `file:///Users/<username>/<projectdir>/data:text/html,%3Ch1%3EHello,%20world!%3C/h1%3E`

However, the file is not present. The browser showed the following view, which is obviously unsatisfactory:

 ![research_1](https://europe1.discourse-cdn.com/katalon/original/3X/1/8/182dcdd5c20a07be5720ea277228447e66c34e02.jpeg)

## `Test Cases/research/2_webdriver_navigate_data`

```auto
import org.openqa.selenium.WebDriver

import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

WebUI.openBrowser('')
WebDriver driver = DriverFactory.getWebDriver()
driver.navigate().to("data:text/html,<h1>Hello, world!</h1>")

```

The 2nd script opened a browser, navigated to the URI:

- `data:text/html,<h1>Hello, world!</h1>`

The browser showed the following view. my Goodness!

 ![research_2](https://europe1.discourse-cdn.com/katalon/original/3X/c/8/c8a708ed4ac4f571de604cf8039215dc7e704743.jpeg)

* * *

This experiment showed me that the Selenium WebDriver API supports `data:` URI with no problem. On the other hand, Katalon’s WebUI API mis-interprets a `data:` URI to be a `file:` URL.

Therefore, I have got 2 points.

1. If you bother yourself to call WebDriver API in your Test Case, you can use `data:` URI now.
2. How [`WebUI.openBrowser(String url)`](https://github.com/katalon-studio/katalon-studio-testing-framework/blob/master/Include/scripts/groovy/com/kms/katalon/core/webui/keyword/builtin/OpenBrowserKeyword.groovy) and [`WebUI.navigateTo(String url)`](https://github.com/katalon-studio/katalon-studio-testing-framework/blob/master/Include/scripts/groovy/com/kms/katalon/core/webui/keyword/builtin/NavigateToUrlKeyword.groovy) make mis-interpretation? I will look at the source code.

I hope that I would be able to modify the implementation of these keywords dynamically by Groovy’s Meta-programming technique to work-around the bug.

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [April 22, 2021, 12:11pm UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/14 "2021-04-22T12:11:26Z")

</div>

@ThanhTo  
@Russ_Thomas  
@duyluong

I looked at the [Source of WebUI.navigateToUrl keyword](https://github.com/katalon-studio/katalon-studio-testing-framework/blob/master/Include/scripts/groovy/com/kms/katalon/core/webui/keyword/builtin/NavigateToUrlKeyword.groovy) and easily found the reason of the mis-interpretation.

Current code:

```auto
    @CompileStatic
    public void navigateToUrl(String rawUrl, FailureHandling flowControl) throws StepFailedException {
        WebUIKeywordMain.runKeyword({
            logger.logDebug(StringConstants.KW_LOG_INFO_CHECKING_URL)
            if (rawUrl == null || rawUrl.isEmpty()) {
                throw new IllegalArgumentException(StringConstants.KW_EXC_URL_CANNOT_BE_NULL_OR_EMPTY)
            }

            URL url = PathUtil.getUrl(rawUrl, "http")
            logger.logDebug(MessageFormat.format(StringConstants.KW_LOG_INFO_NAVIGATING_TO, url.toString()))
            WebDriver webDriver = DriverFactory.getWebDriver()
            webDriver.navigate().to(url.toString())
            logger.logPassed(MessageFormat.format(StringConstants.KW_LOG_PASSED_NAVIGATE_TO, url.toString()))
        }, flowControl, true, MessageFormat.format(StringConstants.KW_MSG_CANNOT_NAVIGATE_TO, rawUrl))
    }

```

The following statement is interesting.

```auto
       URL url = PathUtil.getUrl(rawUrl, "http")

```

This statement makes things complicated, and it looks unnecessary.

Should rather be:

```auto
    @CompileStatic
    public void navigateToUrl(String rawUrl, FailureHandling flowControl) throws StepFailedException {
        WebUIKeywordMain.runKeyword({
            logger.logDebug(StringConstants.KW_LOG_INFO_CHECKING_URL)
            if (rawUrl == null || rawUrl.isEmpty()) {
                throw new IllegalArgumentException(StringConstants.KW_EXC_URL_CANNOT_BE_NULL_OR_EMPTY)
            }

            logger.logDebug(MessageFormat.format(StringConstants.KW_LOG_INFO_NAVIGATING_TO, url.toString()))
            WebDriver webDriver = DriverFactory.getWebDriver()

            webDriver.navigate().to(rawUrl) // java.net.URL class should NOT be involved!

            logger.logPassed(MessageFormat.format(StringConstants.KW_LOG_PASSED_NAVIGATE_TO, url.toString()))
        }, flowControl, true, MessageFormat.format(StringConstants.KW_MSG_CANNOT_NAVIGATE_TO, rawUrl))
    }

```

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [April 22, 2021, 1:07pm UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/15 "2021-04-22T13:07:27Z")

</div>

![image](https://europe1.discourse-cdn.com/katalon/original/3X/a/2/a24b4f1f9311d3a35bf6ae3510c7e7fbb3789669.png)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [April 24, 2021, 5:37am UTC](https://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/16 "2021-04-24T05:37:53Z")

</div>

@Russ_Thomas

I have got a solution for this issue. See the following topic.

> [@Enabling Data URL in Katalon Studio](http://forum.katalon.com/t/enabling-data-url-in-katalon-studio/54146):
>
> I have published a GitHub repository. [https://github.com/kazurayam/katalon-studio-data-url](https://github.com/kazurayam/katalon-studio-data-url)Problem to solve In the Katalon Forum, there are a few posts that ask Katalon Studio to support Data URL. [http://forum.katalon.com/t/urls-supplied-to-katalon-apis-must-support-data-uris/12203/](http://forum.katalon.com/t/urls-supplied-to-katalon-apis-must-support-data-uris/12203/)[http://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/](http://forum.katalon.com/t/katalon-does-not-support-data-urls-rfc2397/23672/) I want to write a Test Case script like this: import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI WebUI.openBro…
