Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Handling Save Dialog Box

by monkster (Sexton)
on Aug 19, 2008 at 07:41 UTC ( #705149=perlquestion: print w/ replies, xml ) Need Help??
monkster has asked for the wisdom of the Perl Monks concerning the following question:

Hi monks,
I am trying to automate some download operations. But a problem that I face is, when I click a form to save some file, it opens up a Save Dialog Box for me to specify the location where it should be saved. Can this be automated in some way such that I can specify the location and save it through script itself.
Even if I cannot specify the location, if it can store in some default location, that is fine..Please tell me how to do this..

Thanks a lot in advance..
Monkster

Comment on Handling Save Dialog Box
Re: Handling Save Dialog Box
by jkva (Chaplain) on Aug 19, 2008 at 07:49 UTC

    Monkster,

    I'm having trouble understanding your question. Which program are you trying to automate? Is this a webbrowser? Or a Perl/TK program or somesuch? Please elaborate, and, if applicable, show the code you've written so far.

      I am trying to automate a web browser. I am using WWW::Selenium to do this..
        I must confess I am not too familiar with WWW::Selenium.

        If there is no way to gain control over the dialog window, you seem out of luck.

        Perhaps then a different approach would be to have another routine save the file you want by analyzing the page html? Perhaps also looking at WWW::Mechanize would be an option.

        Good luck!

      This is a sample code of what I am attempting.
      me::HiRes qw(sleep); use Test::WWW::Selenium; use Test::More "no_plan"; use Test::Exception; my $sel = Test::WWW::Selenium->new( host => "localhost", port => 4444, browser => "*chrome", browser_url => "http://download.co +m/" ); $sel->open_ok("/2000-2001_4-0.html"); $sel->click_ok("link=AVG Anti-Virus Free Edition"); $sel->wait_for_page_to_load_ok("30000"); $sel->click_ok("link=Download Now"); $sel->wait_for_page_to_load_ok("30000");
      After I click 'Download Now', a dialog box pops-up asking me the location where I need to save the file (.exe in the above example). Could you please tell me if I can give the location also through script itself so as to eliminate user interaction..
        Could you please tell me if I can give the location also through script itself so as to eliminate user interaction..

        Why not check http://selenium-rc.openqa.org/?

        See I can't interact with a popup dialog. My test stops in its tracks!

        You can, but only if the dialog is an alert or confirmation dialog. Other special dialogs can't be dismissed by javascript, and thus currently cannot be interacted with. These include the "Save File", "Remember this Password" (Firefox), and modal (IE) dialogs. When they appear, Selenium can only wring its hands in despair.
        monkster:

        If you can't talk to the dialog box using normal methods, you might be able to send a list of keypress events to the application to set the filename and press the OK button. ...just a thought...

        ...roboticus
Re: Handling Save Dialog Box
by brycen (Monk) on Aug 19, 2008 at 18:15 UTC
    The download location on the client is a matter of the browser. In other words, you can't control it. All you can provide is a default file name.

    There may be a browser specific hack (probably for IE). But there is (and should be) no general solution. The browser user needs to have control over file download.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://705149]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2014-07-13 18:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (251 votes), past polls