How to verify whether the file gets downloaded using Selenium ?

Answered

How to verify whether the file gets downloaded or not thru selenium code?
Can I able to get the file name which is getting downloaded and I want to verify that filename is proper or not…
Anyway I am using following code to prevent popup and for downloading the file.But I need to verify whether it is downloaded or not..


fxProfile.setPreference("browser.download.folderList",2);

fxProfile.setPreference("browser.download.manager.showWhenStarting",false);

fxProfile.setPreference("browser.download.dir","C:\\Users\\rreddy\\Desktop\\My");

fxProfile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/pdf");

fxProfile.setPreference("browser.download.manager.showWhenStarting", false);

fxProfile.setPreference("browser.download.manager.focusWhenStarting", false);

fxProfile.setPreference("browser.helperApps.alwaysAsk.force", false);

fxProfile.setPreference("browser.download.manager.alertOnEXEOpen", false);

fxProfile.setPreference("browser.download.manager.closeWhenDone", false);

fxProfile.setPreference("browser.download.manager.showAlertOnComplete", false);

fxProfile.setPreference("browser.download.manager.useWindow", false);

fxProfile.setPreference("browser.download.manager.showWhenStarting",false);

fxProfile.setPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false);

fxProfile.setPreference( "pdfjs.disabled", true );

Add Comment
  • 1 Answer(s)
    Best answer

    Hi Ravindra ,

    In most of the case when you file is getting downloaded the extension would be “.part”. You can write java code to monitor .part presence.
    The moment “.part” goes away your file is downloaded else there are some other ways which is think may not suite your requirement

    But still if your code is on linux then you can try starting a new process from java and invoking wget command and wait for the process to complete, but i really doubt this approach in Functional testing

    Supporter Answered on November 7, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.