1

A few years ago I made a program in .NET that uses the webbrowser control. With that I was able to automatically log in to a website, navigate, and download pictures. It was GUI based since it was using the webbrowser control. It had the advantage that I could follow along and see if something went wrong.

What is the best way forward to replicate that idea in Java? Is there a similar free control that acts as a webbrowser and gives access to the DOM?

I suspect the optimal way would be to use the Google Chrome Developer tools to replicate the login via GET/POST methods, but at first would prefer the webbrowser approach.

5
  • 2
    You can do it with Selenium Commented Jul 9, 2019 at 9:23
  • 1
    Check here : toolsqa.com/selenium-tutorial Commented Jul 9, 2019 at 9:26
  • 1
    If you want to do is really web browser GUI based you could use Java's Robot Class, though that's probably a lot of work Commented Jul 9, 2019 at 9:27
  • I will look into Selenium. It looks like it is enough for my needs here. The robot class might come in handy at some point. Thanks for that! Commented Jul 9, 2019 at 9:31
  • Even if it is possible to do it in Java, you might prefer doing it in Javascript. There are tons of javascript unit testing frameworks that provide all the functionalities you need in order to control the browser and natively interact with it. Commented Jul 9, 2019 at 9:41

3 Answers 3

1

You can use Selenium for that. It is a free (open source) automated testing suite for web applications across different browsers and platforms. It mainly focuses on automating web-based applications.

Sign up to request clarification or add additional context in comments.

Comments

1

In Java, You can use Selenium which will give you full control on Web-Browsers as well as DOM. In Selenium Web Driver is a class which provides full automated control of a browser that we want to use.

This may help You! Thanks!

Comments

0

You could use the JavaFX webView, class javafx.scene.web.WebView.

It uses a Webkit engine that is HTML 5 compliant and seem to be up to date (it was in java 8 & 9). The engine has interraction with the JS engine that may help to introspect and navigate.

Example to get the "window" JS object:

JSObject window = (JSObject) webView.getEngine().executeScript("window");

Webview ewample: JavaFx Webview HTML5 DragAndDrop

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.