question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add support for data urls?

See original GitHub issue

The Firefox driver (and it seems the Chrome driver as well) support data urls, a way to call driver.get("data:text/html;charset=utf-8," + pageAsText); to load a text string as a page. I know HtmlUnit can do this by calling its custom method, but would it be possible to expand this to work with the common interface other drivers are using?

Calling this now returns a java.net.MalformedURLException

I would like to write a single test that could be ran on multiple drivers by calling driver.get() instead of having to add a custom implementation for HtmlUnit driver.

More info on data urls: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs https://newbedev.com/put-a-string-with-html-javascript-into-selenium-webdriver https://stackoverflow.com/a/65446466/1341887

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
rbricommented, Sep 18, 2021

HtmlUnit is able to handle this kind of urls - have done the fix here in the driver and added some tests

Btw this adds also support for the javascript: protocol.

Many thanks for this report.

0reactions
skyhiridercommented, Sep 18, 2021

Thanks for the fix, by javascript protocol you mean using “data:application/javascript” and loading a javascript ?

Searching for javascript protocol resulted in seemingly unrelated results.

Or did you mean now being able to call scrips like this “data:text/html,<script>alert(‘hi’);</script>” ?

Edit: nevermind, had a look at your new unit test and its “driver.get(“javascript:void(document.title=‘Hello’)”);” Never used this before, will need to check where this is documented for either selenium or one of the browsers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Data URLs - HTTP - MDN Web Docs - Mozilla
Data URLs, URLs prefixed with the data: scheme, allow content creators to embed small files inline in documents. They were formerly known as ......
Read more >
Using Data URLs Effectively with Cascading Style Sheets
Data URLs are a clever way of embedding images in HTML. Instead of linking to an image stored locally on the server, the...
Read more >
Is there a way to add data scheme support (RFC 2397) to java ...
I'm working with a third-party library that uses URL s constructed from strings to retrieve images and want to pass image data directly....
Read more >
data-urls - npm
Start using data-urls in your project by running `npm i data-urls`. There are 360 other projects in the npm registry using data-urls.
Read more >
data URLs - GitHub
The data-url library adds support for the data protocol as specified in RFC 2397. There are several ways to create data URLs. Most...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found