Tomcat7194 has asked for the wisdom of the Perl Monks concerning the following question:

Hi all.

I'm trying to do some web automation with WWW::Mechanize. Basically I'm trying to access the upload page on Gather.com and upload a photo--by automating this, I could upload photos to the site from a mobile phone which doesn't support Java (send photos to email, have a script take them and upload).

WWW:Mechanize seems like the obvious choice, but the uploading menu on the site is actually a Java applet which opens a Java dialog to select files. WWW::Mechanize doesn't detect this, so it can't handle the selection of an actual file. I tried to intercept AJAX requests and whatnot to do this directly, but I'm not seeing anything useful going to the server.

Is there any programmatic way to automatically interact with a Java applet? A module would be perfect--command line tools might be an option too...

Any ideas? Thanks, Tom

Replies are listed 'Best First'.
Re: Automation and Java Applet
by Gangabass (Vicar) on Apr 08, 2009 at 07:34 UTC

    You can emulate this behavior via HTTP requests

      I could definitely emulate those behaviors with LWP::Useragent, but the part I don't understand is where the actual transfer of the image file takes place. Those HTTP requests don't seem to contain anything other than an image ID.

      Am I missing something here, or would the the image have to be transfered separately?

      Tom

        You tell us. Potentially employ Wireshark to see what gets transferred over the network, if the HTTP Live Headers aren't enough.

Re: Automation and Java Applet
by Anonymous Monk on Apr 08, 2009 at 03:14 UTC
    I tried to intercept AJAX requests and whatnot to do this directly, but I'm not seeing anything useful going to the server. How did you try?

    Is there any programmatic way to automatically interact with a Java applet? A module would be perfect--command line tools might be an option too...
    Aside from various GuiTest modules, there isn't much point when dealing with HTTP.

      I used Live HTTP Headers and Firebug. Here's the dump of POST commands sent via Live HTTP Headers:

      POST /publishList.ajax command=move&itemId=3659174697246841&from=out&t +o=in&setName=everyone&url=http%3A%2F%2Fwww.gather.com%2FsharePhoto.ac +tion POST /publishPhotosToAlbum.action albumId=11096&allowRating=on&allowCo +mments=on&commentCriteria=everyone&restriction=everyone&uploadSession +Id=499301239163696561&fileId=3096224745628977 POST /uploadStatus.jspf contentId=11096&contentType=image&fileId=30962 +24745628977&latitude=37&longitude=-95&zoomLevels=&contentIds=30962247 +45628977&captions=&tagField=&address=&save=Save%20and%20Continue