Selenium-Python find out when a download has completed

0 votes
I've used selenium to initiate a download. After the download is complete, certain actions need to be taken, is there any simple method to find out when a download is complete?

I am using the Firefox driver.
Sep 5, 2018 in Selenium by Martin
• 4,320 points
20,733 views

1 answer to this question.

0 votes

There is no built-in to selenium way to wait for the download to be completed.

The general idea here would be to wait until a file would appear in your "Downloads" directory.

This might either be achieved by looping over and over again checking for file existence:

Check and wait until a file exists to read it:       

import os.path
import time

while not os.path.exists(file_path):
    time.sleep(1)

if os.path.isfile(file_path):
    # read file
else:
    raise ValueError("%s isn't a file!" % file_path)

Hope this helps!!

If you need to learn more about Python, It's recommended to join Python Programming course today.

Thanks!

answered Sep 5, 2018 by Meci Matt
• 9,460 points

edited Feb 7, 2020 by Gitika
File_path is downloads folder path ? or any other?

Hi Sudheer,

File_path work as a directory where the downloaded file will exist.

Related Questions In Selenium

+1 vote
1 answer
0 votes
1 answer

Can we perform zoom-in or zoom-out actions in a webpage using Python Selenium?

Hello Ruhi, to perform Zoom-in or Zoom-out ...READ MORE

answered Jul 29, 2019 in Selenium by Anvi
• 14,150 points
11,888 views
0 votes
1 answer
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,687 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,149 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,230 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,881 views
0 votes
1 answer
+1 vote
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP