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

Pre-run executables are commonly used to change browser settings and VM configurations before a test starts. This page provides a few examples these scripts, and covers setting prerun as a desired capability during test configuration. You can find more information on the prerun capability in Test Configuration Options.

Root and Administrative Permissions on Sauce Labs Virtual Machines

Note that sudo access is not allowed on Linux/Mac virtual machines. Administrative access is not allowed on Windows VMs.

Write a configuration script to enact changes to the browser or VM

This example script disables the Warning that Safari pops up when using basic HTTP authentication to access a website.
defaults write WarnAboutFraudulentWebsites false

Match File Types to Your Operating System

When creating your executable file, take into account the operating system you'll use for your tests. For example, Bash commands won't work on Windows machines, which instead require a .bat or .com file.

Store your configuration script in a location where Sauce can access it

For example, your script could be stored in GitHub or in  Sauce StorageYou can also use Gist to easily host your executable file. Make sure to use the link containing the raw file contents.

Set the prerun capability In your test script to the location of your pre-run executable

This example sets prerun to point to, whch hosts the script used as an example in step 1.

desired_capabilities['prerun'] = { 
    'background': 'false' 

This example accesses the same script from Sauce Storage:

desired_capabilities['prerun'] = {
    'background': 'false' 

Run your test.

The prerun script will download to your Sauce Labs VM and execute prior to the test itself.