put a string with html/Javascript into selenium webdriver

You could load an empty page eg:

<html></html>

And then set it's innerHTML

ChromeDriver driver = new ChromeDriver();
driver.get("file://empty-page.html");
String innerHtml = "<head>...</head><body onload="...">...</body>";
driver.executeScript("document.innerHTML = " + innerHtml);

Then fire the load event on the body

driver.executeScript("$(document.body).trigger('load');");

Then get the resultant HTML

String result = driver.executeScript("document.body.innerHTML;");

this code can load any html string which include js and css.

html_bs64 = base64.b64encode(innerHtml.encode('utf-8')).decode()
driver.get("data:text/html;base64," + html_bs64)

If you don't want to create a file or load a URL before being able to replace the content of the page, you can always leverage the Data URLs feature, which supports HTML, CSS and JavaScript:

ChromeDriver driver = new ChromeDriver();
html_content = """
<html>
     <head></head>
     <body>
         <div>
             Hello World =)
         </div>
     </body>
</html>
"""

driver.get("data:text/html;charset=utf-8," + html_content)