The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing


External Resources

More Info

Page tree
Skip to end of metadata
Go to start of metadata

You can use a pre-run executable script to download files from a public location to the Sauce Labs virtual machine running your tests. This topic contains example scripts for downloading remote files on different operating systems, and details configuring the prerun capability in your tests. 

NOTE: Custom data/files that are downloaded or created during tests only reside in the VM that the test is currently running on. This information is not stored anywhere, and is discarded along with the VM once the test completes.

Select an OS for detailed instructions:

OS X 10.6, 10.8, 10.9, 10.10

This shell script will fetch the file at the URL and save it to /tmp/file.txt.

curl -o /tmp/file.txt

Windows 7, 8, 8.1

This batch file accomplishes the same thing as the OS X curl method, but using bitsadmin.exe since Windows doesn't ship with curl.

@echo off 
bitsadmin.exe /transfer "JobName" C:\Users\Administrator\Desktop\file.txt

Windows XP

This batch file creates a VBScript file, dl.vbs, which will perform the download, and then runs it:

@echo off

echo strFileURL="" > C:\dl.vbs
echo strHDLocation = "C:\file.csv" >> C:\dl.vbs
echo Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP") >> C:\dl.vbs
echo "GET", strFileURL, false >> C:\dl.vbs
echo objXMLHTTP.send() >> C:\dl.vbs
echo If objXMLHTTP.Status = 200 Then >> C:\dl.vbs
echo Set objADOStream = CreateObject("ADODB.Stream") >> C:\dl.vbs
echo objADOStream.Open >> C:\dl.vbs
echo objADOStream.Type = 1 'adTypeBinary >> C:\dl.vbs
echo objADOStream.Write objXMLHTTP.ResponseBody >> C:\dl.vbs
echo objADOStream.Position = 0 'Set the stream position to the start >> C:\dl.vbs
echo Set objFSO = Createobject("Scripting.FileSystemObject") >> C:\dl.vbs
echo If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation >> C:\dl.vbs
echo Set objFSO = Nothing >> C:\dl.vbs
echo objADOStream.SaveToFile strHDLocation >> C:\dl.vbs
echo objADOStream.Close >> C:\dl.vbs
echo Set objADOStream = Nothing >> C:\dl.vbs
echo End if >> C:\dl.vbs
echo Set objXMLHTTP = Nothing >> C:\dl.vbs

cscript.exe C:\dl.vbs


This shell script downloads file.txt at to the /tmp directory.

wget -O /tmp/file.txt

Set Prerun Capability

After you've created the download script, use the prerun capability in your test script to point to its location.

If your script is in a publicly accessible location, you need to add the URL to the prerun capability.

capabilities['prerun'] = "http://location.of/"

If your script is in Sauce Storage, you just need to indicate that location, and then the name of the script.

capabilities['prerun'] = ""