Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get java script console ouput of browser in java?

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.

like image 840
Pradeep Avatar asked Jul 14 '26 23:07

Pradeep


1 Answers

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 :D

like image 130
Pradeep Avatar answered Jul 16 '26 12:07

Pradeep



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!