Skip to end of metadata
Go to start of metadata

You can create a pre-run executable script that will download a file from a public location to the Sauce Labs virtual machine running your tests. This topic contains examples of scripts for that purpose, based on the operating system you are using for your tests, and how to configure the prerun capability in your tests to reference them. 

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 will download the file to the /tmp directory.

wget -O /tmp/file.txt

Setting the prerun Capability

After you've created the download script, you need to 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'] = "" 
  • No labels