0

Is there a way in java to "click" an html button for a specific url? I dont want to go through designing a GUI or opening a browser, I just want to write a program to "click" a button as a user would in a web browser for a specific website. Is the possible with a java program?

2
  • 2
    You can see Selenium RC or Selenium WebDriver, but I'm not sure if it's exactly what you need, because these tools will open your browser to click on the button Commented Mar 23, 2013 at 3:46
  • Ignore my vote to close as a duplicate, I misunderstood the question initially. Commented Mar 23, 2013 at 3:51

2 Answers 2

2

If I understood correctly .... you would like to emulate an interaction with the browser, programmatically. It's doable with java. You just need to open a http connection to the page's url you want to hit, with the expected form's parameters set up. Since it's a form it's easier and cleaner to do with post request.

You can use this library if you don't want to struggle with low level java api.

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

Comments

2

HtmlUnit is a great library offering such functionality, and its project page alone uses a description perfectly matching your question:

HtmlUnit is a "GUI-Less browser for Java programs". It models HTML documents and provides an API that allows you to invoke pages, fill out forms, click links, etc... just like you do in your "normal" browser.

It is specifically a way to simulate a browser for testing purposes...

It even supports JavaScript. If that's a requirement for your project, HtmlUnit is worth looking into.

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.