Case Study: Wait for File Download to Complete Safely in Selenium

How to increase reliability in an automated test for a file download.

Zhimin Zhan

--

A repost of my daughter’s article, I added a few notes. This is also included in my “How to in Selenium WebDriver” series.

This article will show you how to verify a file download completes successfully in Selenium WebDriver.

Table of Contents:
Test Design
Fixed Wait
Check the Downloaded File’s Size
Wait for the Browser Download to Complete
Complete Test Script
Zhimin’s Notes

The test site for this article is http://zhimin.com/books/pwta. There is a sample PDF download that I will use for the tests.

Test Design

The test design is quite straightforward.

  1. Click the download button
  2. Wait…
  3. Verify the file contents

--

--

Zhimin Zhan

Test automation & CT coach, author, speaker and award-winning software developer. Help teams succeed with Agile/DevOps by implementing real Continuous Testing.