Javascript from Java - document object

I am trying to call a java script function that creates an html div structure using for example

/* ... */
document.createElement("div");
/* ... */

      

Unfortunately, I don't have a window and / or document object if I run this script directly from Java, as opposed to running it in a browser. Can someone give me some advice on how to use or modify the javascript code? Is there a way to create a document object myself? Many thanks.

Regards

Sasha

+3


source to share


1 answer


Rhino and Nashorn do not provide browser objects like window

and document

. If you need these objects, you will have to supply them yourself. Try HTMLUnit , which provides an implementation of these objects for writing unit tests.



+2


source







All Articles