Manage Google Chrome with Java

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

Say that I'm just calling a function that passes the URL as a parameter, and the page will load.

I am writing a java program that I can use to automatically save files to the server, so I do not need to enter cpanel and then do it manually, I can use php to save the files, but I need to check how the site is designed. But since I'm new to Java, I'm not very good at business.

Thanks Sreejith

+4
source share
3 answers

I doubt that there is a way to control a web browser without knowing or having its API. If the web browser you want to control does not provide an API for your Java, then this is not possible.

If you want full control of your web browser, you should try to develop a plug-in using your APIs, not through JAVA.

If you just want to open the link in your default browser, try the following:

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

This code opens the URL of your default web browser. I used this to open many forum pages because it requires a login session to my web browser and saves all pages at once.

+8
source

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

+1
source

You can try Selenium here :

 import org.openqa.selenium.chrome.ChromeDriver; public class App { public static void main(String[] args) throws Throwable { ChromeDriver driver = new ChromeDriver(); System.setProperty("webdriver.chrome.driver", "/usr/bin/google-chrome"); // And now use this to visit Google driver.get("http://www.google.com"); } 

}

Add Maven Dependency:

  <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.42.2</version> </dependency> 
0
source

Source: https://habr.com/ru/post/1343034/


All Articles