Confirmation of downloaded file

Hi! I am trying to run an automation test with Java Selenium Webdriver for downloading a file on LambdaTest. How do I confirm if the file is downloaded or not?

Hello! Hope all’s well!

Once you have downloaded the file, you can simply include following code in your class to assert if the file is downloaded:

        Assert.assertEquals(((JavascriptExecutor) driver).executeScript("lambda-file-exists=<filename>.<filetype>"), true);

Running this command confirms if a file is downloaded or not and accordingly you can decide your next plan of action. Also, here you’ll notice “lambda-file-exists” which is a Lambda-hook offered by LambdaTest. For more Lambda-hooks, you can visit https://www.lambdatest.com/support/docs/lambda-hooks/.

Happy testing!

2 Likes