How do I verify file download in Selenium Python?

How do I verify file download in Selenium Python?

Hi Ian!

To verify file download for Selenium automation testing with Python, you can use the below test case -

def test_verify_download(self):
		# try:
		driver = self.driver
		driver.get('https://chromedriver.storage.googleapis.com/index.html?path=79.0.3945.36/')
		driver.maximize_window()
		sleep(2)
		driver.find_element_by_xpath("/html/body/table/tbody/tr[]/td[2]/a").click()
		sleep(5)
		if(driver.execute_script("lambda-file-exists=chromedriver_win32.zip") == True):
			driver.execute_script("lambda-status=passed")
			print("Tests are run successfully!")
		else:
			driver.execute_script("lambda-status=failed")

Here is the sample GitHub repo for the same -