1

I have to check whole application and I need to handle an Icon, where after click a file is downloaded. How to handle it? Is there any other way, than NOT to click on the icon?

  • Why do you want to download the file? Are you going to do anything with it? Checking that a browser can download a file is a pretty useless test. Checking that there is a file on a server, or checking that the correct file is on the server are much better tests. – Ardesco Sep 4 '15 at 10:12
  • 1
  • Dee, consider accepting your answer. It's fine to accept your own answer, although be weary of things that say "cannot" - sometimes it just happens that we don't know how it can. =) – corsiKa Oct 19 '15 at 15:56
1

I was a bit tricky. Answer could be: Selenium IDE cannot do that. Download dialogs cannot be handled from IDE. But this is jus a half of the question.

If we need to handle somehow the situation, that there is a clickable Icon followed by download dialog, we should somehow test it.

Solution is settings of the Firefox. We can setup Firefox to download a file of certain type wihout any dialog. Then you can just click the download link.

Settings in Firefox is located here: Hamburgermenu - Options - Applications - file type on your choice

  • select Download the file directly. You have to check dowloaded files manually.

Another option could be to display file in Firefox (if possible), for example XML, PDF or SVG file, but I did not manage to focus IDE to another tab and support for managing Firefox tabs is not available so far (matter of possible change).

0

You can configure selenium to handle the download dialog in your code. Here it is in Ruby:

# create a download directory
@download_dir = File.join(Dir.pwd, UUID.new.generate)
FileUtils.mkdir_p @download_dir

# create a new profile
profile = Selenium::WebDriver::Firefox::Profile.new

# set the download directory
profile['browser.download.dir'] = @download_dir

# set that you want to use the custom directory (1 = default path, 2 = custom, 0 = desktop)
profile['browser.download.folderList'] = 2

# set what mime types of files to download automatically
profile['browser.helperApps.neverAsk.saveToDisk'] = 'application/pdf'

# if you're downloading a pdf you'll want to tell firefox to allow a pdf to be handled within the browser
profile['pdfjs.disabled'] = true

# attach the configured profile to the driver.
@driver = Selenium::WebDriver.for :firefox, profile: profile
  • The OP has asked this question specially about Selenium IDE. – Dhiman Sep 3 '15 at 18:40
  • @Dhiman This still works with code exported from Selenium IDE. I'm not sure what point you're trying to make. – Jake Johnson Sep 3 '15 at 19:23
  • Sorry, question is about Selenium IDE ONLY. No file Utils are available in IDE. I will not put minus here, for now..., but I answered it by myself... – Dee Oct 16 '15 at 10:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.