How to use lambda-file-exists validation when not knowing the file name

179 views Asked by At

Im creating an automation testing using Selenium+Lambda and have to validade if a file is downloaded.

I found the following solution in lambda support page https://www.lambdatest.com/support/docs/download-files-using-lambdatest-selenium-grid/

Indeed i implemented the following and worked, my test its validating if a file is downloaded or not. "Assert.assertEquals(((JavascriptExecutor) driver).executeScript("lambda-file-exists=myw3schoolsimage.jpg"), true);"

The problem is.. i had to pass the file name hardcoded in that command, and that wont work for my scenarios as my files have dinamic names.

There is a way handle it?

Thanks!

1

There are 1 answers

0
Lambdatest On

Check whether the downloaded file exists in the test machine.

((JavascriptExecutor) driver).executeScript("lambda-file-exists=file-name.file_format");

List down the file in the download directory.

print driver.execute_script("lambda-file-list={match string with filename}");

ie:

driver.execute_script("lambda-file-list=sample")

Response: List of files in downloads dir starting with sample