Accessing downloaded files in real-browser testcases - Web Performance
Menu

Accessing downloaded files in real-browser testcases

Dealing with file downloads is considered by many to be problematic when developing testcases with Selenium/WebDriver. Web Performance Tester (WPT) makes this task relatively effortless when working with Chrome – when the virtual user will initiates a download (by clicking something), the file will be downloaded into a directory that exists only for the duration of that testcase. This solves one problem – running out of disk space due to files downloaded during test iterations – because when the testcase ends, the temporary folder is removed along with the downloaded files.

Some tests require validating the content of the file, so the next problem is how to locate the file and perform some additional logic on it. WPT 6.5 adds a new API to our scripted step that gives javascript code access to the most recently downloaded file. This example shows how to move the file to another folder (that will not be deleted) so that it can be verified later. With a little more effort, the script could read the file and verify the file contains a specific string (as a simple example). Note that this requires use of java.io classes from within javascript. This can be a bit tricky – feel free to contact us for some help with this.

Chris Merrill, Chief Engineer

Add Your Comment

You must be logged in to post a comment.

Resources

Copyright © 2024 Web Performance, Inc.

A Durham web design company

×

(1) 919-845-7601 9AM-5PM EST

Just complete this form and we will get back to you as soon as possible with a quote. Please note: Technical support questions should be posted to our online support system.

About You
How Many Concurrent Users