0

My function is that when user click the button, a filed is downloaded. Normally, a dialog from native OS is there to notify you

In the Selenium test, I do not know how to check if such dialog is opened (Indication of file downloaded successfully). I do not want Selenium to download it, just looking for the sign of a successful download

Loredra L
  • 1,369
  • 2
  • 14
  • 29

1 Answers1

1

Therre is no direct way from Selenium but you can check if the downloaded file exists in the path Using java.io.File:

File f = new File(filePathString);
if(f.exists() && !f.isDirectory()) { 
    // do something
}

as per How do I check if a file exists in Java?

Community
  • 1
  • 1
Kushal Bhalaik
  • 3,250
  • 4
  • 19
  • 38
  • Added as accepted since if you enable auto download using Firefox Profile, it would work, but if they asking for Save option then this would not work. – Loredra L Mar 17 '17 at 10:45