As a matter of fact, I have just done this. What I found to be the
easiest method is to create a profile that you will only use for your
Webdriver testing. Start Firefox with that profile (firefox -P
<profilename>) and set up all your preferences, such as saving certain
MIME types. This is most easily done by doing exactly what you will do
in your test and then clicking "Save" and "Always do this." That will
add that MIME type to your list of file types that is handled
automatically in Firefox. You can confirm it saved your action by
going into Tools | Options and then clicking on Applications. You
should be able to find the MIME type you just dealt with and confirm
that it will Save as the default action.
Then, in your webdriver code, tell it to use this same profile by
setting the property webdriver.firefox.profile, and you're good to go.
The one caveat to this is that if your file is an executable, Firefox
will not enable the "Always do this" checkbox. At that point, you need
to edit one of the files in the profile.
This is kind of out of scope for Webdriver, but I've spent a lot of
time on it so I thought I'd share. :)
cheers,
Penelope
On Nov 24, 2:06 pm, "Eran M." <
eran....@gmail.com> wrote:
> See issue 95 <
http://code.google.com/p/webdriver/issues/detail?=95>.
> Mozilla Developers Center is not the most organized site in existence, but
> once you find out the exact component you should implement, it's probably
> just a matter of making sure that file is being handed to the download
> manager.
>
> Eran
>
> 2009/11/24 Prasanna <
prasanna...@gmail.com>
>
>
>
> > I can try that. If you can point me to docs/wiki, that would be nice.
>
> > On Tue, Nov 24, 2009 at 2:53 AM, Eran M. <
eran....@gmail.com> wrote:
>
> >> Hi,
>
> >> If your purpose is to save the file, it may be possible to extend the
> >> extension to handle the MIME type you are trying to open and get it to be
> >> automatically downloaded. I'm updating the issue with some links to related
> >> Mozilla documents.
> >> What point is there in opening the file for you? Any program which will be
> >> opened cannot (and will not) be controlled using WebDriver, unless it's a
> >> script that's processing the file.
>
> >> Eran
>
> >> 2009/11/24 Simon Stewart <
simon.m.stew...@gmail.com>
>
> >>> No, there's currently no way to handle the "save file" dialog. I won't
> >>> be working on this feature until we've got native events for all
> >>> platforms, can handle javascript alerts and prompts cleanly, have the
> >>> Chrome driver stable and can access sites with insecure SSL certs.
>
> >>> I am, however, happy to receive, review and apply patches, so if
> >>> you're willing to work on the feature, it'll be in webdriver sooner.
>
> >>> Simon
>
> >>> On Tue, Nov 24, 2009 at 2:43 AM, Prasanna <
prasanna...@gmail.com> wrote:
>
> >>> > At the height of being repetitive, is there a way to handle file
> >>> > download dialogs using webdriver? I do see Issue 27,
> >>> >
http://code.google.com/p/webdriver/issues/detail?id=27, and tried the
> >>> > javascript hacks but to no avail.
>
> >>> > Basically this is what happens, I have a button which when clicked
> >>> > will display the file download prompt with two radio buttons, "Open
> >>> > with" and "Save File". By default "Open With" is selected. Then there
> >>> > are 'Ok' and 'Cancel ' buttons. The first thing I would like to do is
> >>> > when the download prompt comes up, click Ok, so that the file is
> >>> > opened.
>
> >>> > For this I tried:
>
> >>> > ((JavascriptExecutor) driver).executeScript("window.confirm = function
> >>> > (msg) { return
> >>> > true; }");
>
> >>> > before clicking the button to download. Did not work.
>
> >>> > The next I want to select the 'Save File' radio button and then Click
> >>> > 'Ok'.
>
> >>> > Could someone please let know some workarounds. Thanks
>
> > --
> > - Prasanna- Hide quoted text -
>
> - Show quoted text -