Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling Google Chrome using Java

I was looking for a way to control google chrome or firefox or internet explorer using java.

Say like I simply call a function passing the URL as the parameter and the page will be loaded.

I'm writing a java program that I can use to automatically save files on server so that I don't have to login to cpanel and then make it manually, I can use php to do save the file(s) but I need to test how the site design is. But as I'm new to Java I don't have much knowledge of doing things.

Thanks, Sreejith

like image 700
sreejith Avatar asked Jan 20 '23 07:01

sreejith


2 Answers

I doubt if there is a way to control the web browser without knowing or having its APIs. If the web browser you want to control does not provide an API for your java then it is impossible.

If you want to be able to fully control your web browser, you should try to develop plug-in using their APIs, not via JAVA.

If you just want to open a link in your default web browser, try this:

java.awt.Desktop.getDesktop().browse(java.net.URI.create("http://google.com"));

This code opens the url in your default web broswer. I used this to open lots of forum pages because it requires login session from my web browser and saves the pages all at once.

like image 116
gigadot Avatar answered Jan 22 '23 21:01

gigadot


You might be better off using cPanel XML api for what you are trying.

like image 43
Bala R Avatar answered Jan 22 '23 19:01

Bala R