aspose file tools*
The moose likes Java in General and the fly likes Pushing A Button on a Webpage Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Pushing A Button on a Webpage" Watch "Pushing A Button on a Webpage" New topic
Author

Pushing A Button on a Webpage

Matt DeLacey
Ranch Hand

Joined: Oct 12, 2000
Posts: 318
Is there a way to have a Java Program go to a webpage, and push a button on that webpage?

With Respect,
Matt
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Never actually done it or study it thoroughly..
but you could investigate using javascript out of a java program to execute the submit method or whatever other button-method on the web-page.
just a thought


The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
HttpUnit might give you some guidance...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Well, if you KNOW where the button is on the screen, then you can use the Robot class to move the mouse to that pixel location and then use the Robot class to press the mouse. Seems sort of "manual" though :roll: .


"JavaRanch, where the deer and the Certified play" - David O'Meara
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Cindy Glass:
Well, if you KNOW where the button is on the screen, then you can use the Robot class to move the mouse to that pixel location and then use the Robot class to press the mouse. Seems sort of "manual" though :roll: .

Wouldn't that apply to Swing instead of HTML?
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Well it is AWT not SWING, but yes. So that means that you would need to bring up the page in a Frame. Any self respecting Browser written in Java can do that . Doesn't sound like a very efficient method - does it?
Seems that there must be a better way.
We use a program called WinRunner to simulate keystrokes in a batch mode. Invoking something like that might work.
Dave Landers
Ranch Hand

Joined: Jul 24, 2002
Posts: 401
If you know what the button does, you can fake it. So do a View Source in your browser and figure out what the button's FORM is doing. Then you could construct a POST request that does the same thing that the button does.
Send that POST using URLConnection. Get back the result, blah blah blah.
Not exactly "Pushing the Button", but has the same effect on the server.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Dave Landers:
If you know what the button does, you can fake it. So do a View Source in your browser and figure out what the button's FORM is doing. Then you could construct a POST request that does the same thing that the button does.
Send that POST using URLConnection. Get back the result, blah blah blah.
Not exactly "Pushing the Button", but has the same effect on the server.

I think, httpUnit does automate some parts of the above. I might be wrong, though - it's a while since I used it...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pushing A Button on a Webpage
 
Similar Threads
jsp to swing
Browser back button problem
Saving content of an Applet as a picture
help out
Is there a way to automatically default a webpage to a specific area upon load?