Add support for data urls?
See original GitHub issueThe 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:
- Created 2 years ago
- Comments:6
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.
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.