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?
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).
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