Win a copy of Rust Web Development this week in the Other Languages forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Pushing A Button on a Webpage

 
Ranch Hand
Posts: 318
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1211
Mac IntelliJ IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HttpUnit might give you some guidance...
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 401
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic