Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am now using the selenium RC with C#. I want to download a file from application. when I am clicking on a button one pop-up dialog box is coming which tells open,save and cancel. I am not able to handle this type of pop-up through selenium RC(C#).

Can anyone help me on this to resolve it as soon as possible.

Thanks in advance,
Dinesh
Posted
Updated 28-Dec-12 1:05am
v2

I ran into same issue using selenium, im making the assumption that when that box pops up you always wish to download it correct?

I ended up running my selenium through firefox and created a custom firefox profile in order to run it. In doing so i was able to say any file type of CSV automatically save it to c:\temp directory.

Here is my below MimeTypes.rdf and preferences.js for firefox. Using selenium you have the ability to run selenium using a custom firefox profile, this is well documented and plenty of examples on the internet that you should be able to easily find. A quick search found this link for example: http://garbuz.com/2010/07/31/running-selenium-with-custom-firefox-profile/[^]

mimeTypes.rdf (defines what files you want to auto download)
<rdf:rdf xmlns:nc="http://home.netscape.com/NC-rdf#" xmlns:rdf="#unknown">
         xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:description rdf:about="urn:root">
                   NC:en-US_defaultHandlersVersion="3" />
  <rdf:description rdf:about="urn:mimetype:application/vnd.ms-excel">
                   NC:value="application/vnd.ms-excel"
                   NC:editable="true"
                   NC:description="CSV document"
                   NC:alwaysAsk="false"
                   NC:saveToDisk="true">
    <nc:fileextensions>csv</nc:fileextensions>
    <nc:fileextensions>xls</nc:fileextensions>
    <nc:fileextensions>xlb</nc:fileextensions>
    <nc:fileextensions>xlt</nc:fileextensions>
    <nc:handlerprop rdf:resource="urn:mimetype:handler:application/vnd.ms-excel" />
  </rdf:description>
  <rdf:description rdf:about="urn:mimetype:handler:text/csv">
                   NC:saveToDisk="true"
                   NC:alwaysAsk="false" />
  <rdf:description rdf:about="urn:mimetype:text/csv">
                   NC:fileExtensions="csv"
                   NC:description="CSV document"
                   NC:value="text/csv"
                   NC:editable="true"
                   NC:alwaysAsk="false"
                   NC:saveToDisk="true">
      <nc:handlerprop rdf:resource="urn:mimetype:handler:text/csv" />
  </rdf:description>
</rdf:description></rdf:description></rdf:rdf>



preferences.js (you can basically take your current profile in firefox and add these two lines to it)
user_pref("browser.download.dir", "C:\\temp");
user_pref("browser.download.folderList", 2);
 
Share this answer
 
Hi Thanks David Wimbley,
I am using IE as my browser. So, i couldn't map your solution to my problem.

And i fixed the issue. All i did is go for using the help of ASCII Keycode values and WaitFor condition available in Selenium.

i,e,
// Button - To Trigger File Download Button
selenium.click(Button);
selenium.waitForPageToLoad("10000");
selenium.AltKeyDown();
selenium.AltKeyUp();
Thread.Sleep(3000);
selenium.KeyPressNative("27"); ///27-ESC
Thread.Sleep(3000);


This is the way i did, and found working fine.

Hi Ramasai, try this solution. all the best.
 
Share this answer
 
v2
Hi Thanks David Wimbley,

I am using IE as my browser. So, i couldn't map your solution to my problem.

And i fixed the issue. All i did is go for using the help of ASCII Keycode values and WaitFor condition available in Selenium.

i,e,

C#
// Button - To Trigger File Download Button
selenium.click(Button);
selenium.waitForPageToLoad("10000");
selenium.AltKeyDown();
selenium.AltKeyUp();
Thread.Sleep(3000);
selenium.KeyPressNative("27"); ///27-ESC
Thread.Sleep(3000);




This is the way i did, and found working fine.

Hi Ramasai, try this solution. all the best.
 
Share this answer
 
Hi I have the same problem butmy project is in IE. Can you guide me for a resolution in IE and I have used Selenium RC.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900