I want to run one HTML page with JavaScript and want to access its output in Java. Is there any way to access JavaScript console output of browser in Java code?
First, I tried executing JavaScript using Java (htmlunit) but it gave an error due to jQuery in the JS.
The JS function which I need to execute uses associated HTML elements, and that’s why I preferred to save the page, add my JS to that page, and run it locally. I can then see the output on the JavaScript console, and now I want to get that output in Java code for further processing.
Thanks all for quick responses, we solved the problem using Greasemonkey and firefox. Instead of console we are writing output to the file using one servlet. The installed js inside Greasemokey execute js method and output from that is passed over one Servlet(locally running) get request and it writes input to file and we can use that file in java, Inside file write code just added synchronized block in case multiple links opened by Greasemonkey 😀