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
When his dad brought home a Commodore PET computer, Chris was drawn into computers. 7 years later, after finishing his degree in Computer and Electrical Engineering at Purdue University, he found himself writing software for industrial control systems. His first foray into testing software resulted in an innovative control system for testing lubricants in automotive engines. The Internet grabbed his attention and he became one of the first Sun Certified Java Developers. His focus then locked on performance testing of websites. As Chief Engineer for Web Performance since 2001, Chris now spends his time turning real-world testing challenges into new features for the Load Tester product.