1

I have an "Export" button so after click on it the .csv file with some data is downloaded.

Is there a way to test in Selenium2 the following points:

  • The file is downloaded after click on the "Export" button
  • The downloaded file is a .csv format file.
  • File data is correct. (There are three columns, let them be Column1, Column2, Column3 )

I will really appreciate all of the suggestions on how to do the tings above using Java.

Showme
  • 69
  • 1
  • 3
  • 8
  • Are you able to download after clicks the `Export` button. you didn't receive any downloadable window or native window? – Manigandan Feb 01 '13 at 12:19
  • It depends on the browser. If I use Firefox there is a default confirmation question whether I want to download the file or no. If I use Chrome - the file downloads directly with no confirmation windows. But Firefox is much appreciated. – Showme Feb 01 '13 at 12:44
  • Duplicate of : http://stackoverflow.com/questions/9970959/how-to-download-file-dialogue-using-selenium-ide-on-linux/9977149#9977149 and http://stackoverflow.com/questions/14940015/i-trying-to-download-file-in-firefox-using-the-profile-setting-but-it-does-not-w and http://sqa.stackexchange.com/questions/2197/how-do-i-download-a-file-using-seleniums-webdriver/2595#2595 – Ardesco Feb 22 '13 at 11:08
  • Also have a read of this for a cross browser solution: http://ardesco.lazerycode.com/index.php/2012/07/how-to-download-files-with-selenium-and-why-you-shouldnt/ – Ardesco Feb 22 '13 at 11:08

3 Answers3

1

Actually, It is not possible to handle the Native windows using the selenium web driver. You can go for the third party tool like AutoIT to resolve this kind of issue.

For more info on AutoIT Tutorial and this too.

Community
  • 1
  • 1
Manigandan
  • 5,004
  • 1
  • 28
  • 47
0

In firefox also you can do the same thing.

  1. Create one firefox profile
  2. Change the firefox download setting as it should save files without asking about location to save
  3. Launch the automation using that profile.

FirefoxProfile profile = new FirefoxProfile(profileDir);

driver=new FirefoxDriver(profile);

below you can see how to change firefox file download settings

enter image description here

And then by using by some programming language you can do remaining things

Community
  • 1
  • 1
Santoshsarma
  • 5,627
  • 1
  • 24
  • 39
0

Integrate Sikuli library in your test script. You can easily compare through snapshot.

Sakib
  • 85
  • 2
  • 11
  • Can you explain how this helps with testing downloading files? – reinierpost Feb 04 '13 at 09:19
  • For downloading the file, you have to click the "Export" button using Selenium 2. After that use the find()function of Sikuli. As an example, suppose you have downloaded the file to D:\test directory. Now go to D:\test directory and take the screenshot of downloaded file. Now call find() function with that screenshot after downloading the file. If the screenshot matches with your downloaded file then it will be verified that correct file with correct format has been downloaded. Still if you not clear, let me know please. – Sakib Feb 05 '13 at 09:48
  • Clicking the Export button throws up an OS dialog asking the user for a location to save the file. The file will then need to be saved and opened somehow. I do not see how Sikuli can help us there. – reinierpost Feb 05 '13 at 10:25
  • For OS dialog, take snapshot of "File name" input box, use click() and type() function. You will write the the file location inside type() function. Now take snapshot of "Save" button and use click() function. – Sakib Feb 09 '13 at 17:06
  • Sikuli is a good solution, thanks. Unfortunately it works not really well on Ubuntu. Maybe you do happen to know the solution for Selenium only? – Showme Feb 12 '13 at 16:59
  • There is no Selenium only solution for handling OS dialog. To handle OS dialog you need to use AutoIt, AutoHotKey, Sikuli etc. I'm not experienced about Ubuntu and Sikuli. May be this link can help you - [link](http://playingwithsid.blogspot.com/2012/01/installing-sikuli-automation-tool-on.html) – Sakib Feb 17 '13 at 12:18