• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pushing A Button on a Webpage

 
Matt DeLacey
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpUnit might give you some guidance...
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: .
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic