The Basic Sauce Connect Proxy setup is ideal for non-enterprise users with network configurations that require a proxy to open up communication between Sauce Labs and their web or mobile app.
It is also a key step for any Sauce Connect deployment as a way to verify if you need help from network administrators to complete the configuration. For details, see Validating Your Basic Sauce Connect Proxy Setup.
See the following sections for more information:
NOTE: Sauce Labs recommends setting all of the values above as environment variables to protect your username and api key from exposure, and also for future convenience.
Once you've downloaded the Sauce Connect Proxy, you can validate that it works on your network by completing the following steps:
Launch a tunnel with the following flags, per the Sauce Connect Proxy Command Line Reference:
$ bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY -x $SAUCE_DC -i TUNNEL_ID
SAUCE_USERNAMEis the username assigned to your Sauce Labs account
SAUCE_ACCESS_KEYis the access key associated with that account
SAUCE_DCis the url of the datacenter you need to use. By default, the
-xoption is not required if you're using the default US West data center. If you're using the Read Device Cloud or the European Data Center,
-x SAUCE_DCis required.
TUNNEL_IDis the identifier or name of the tunnel; for more information, see Using Tunnel Identifiers.
Select an appropriate test script. Options might include:
One your existing tests if available
An example from Sauce Labs Demonstration Scripts. Follow the instructions to configure the test before proceeding to step 3 below.
If you are using an tunnel identifier, add the following to the desired capabilities of the test:
TUNNEL_ID is the identifier or name of the tunnel from step 1.
4. When you see
connected, log in to Sauce Labs and go to Tunnels. Under Active Tunnels, you should see the tunnel you've just started.
5. Your next step depends on the outcome of the test:
Congratulations! You're ready to begin automated testing on your local network.
If you're unable to connect, there are a few possible explanations:
Once you've confirmed that your network is configured appropriate for Sauce Connect Proxy, you can start new tunnels as needed.
It is important to be aware of the various options you have for configuring tunnels:
As a best practice, Sauce Labs recommends creating a new tunnel for each test suite or build and tearing it down at the end of the test.
|SC Host (Sauce Connect Host)||The machine in your network on which the Sauce Connect Proxy application is running. In this setup, it has a direct connection to the internet.|
|SUT (Site Under Test)||The site that you're testing. It is on the same local network as the SC Host machine.|
|Tunnel VM (Tunnel Virtual Machine)|
Virtual machine that hosts Sauce Connect on the Sauce Labs side.
REMINDER: Sauce Connect must be on the same network as the website or mobile app under test, but it is not required to set it up on the same machine.
When launching a Sauce Connect tunnel for automated web and mobile app tests, you have two options:
-i (--tunnel-identifier)command to assign the tunnel identifier(s) when starting up Sauce Connect Proxy. Then, you'll need to use the
tunnelIdentifieroption in the desired capabilities of your automated tests. This will trigger your tests to request a specific Sauce Connect tunnel to run your tests through that tunnel.
Sauce Labs recommends using tunnel identifiers so you can have more control and monitoring capability over your tunnel.
Below is an example of how to designate tunnels based on the
tunnelIdentifier option so that it works properly with an automated test.
Launch a new tunnel on the SC_HOST with the following flags, per the Sauce Connect Proxy Command Line Reference:
$ sc_download/bin/sc -u $SAUCE_USERNAME -k $SAUCE_ACCESS_KEY -x $SAUCE_DC -i sc-proxy-tunnel
> sc_download\bin\sc.exe -u %SAUCE_USERNAME% -k %SAUCE_ACCESS_KEY% -x %SAUCE_DC% -i sc-proxy-tunnel
Every Sauce Connect tunnel spins up a fresh virtual machine (VM) that is used only for your tests; VMs are destroyed once the tunnel is closed. A recommended Sauce Connect best practice is to create a new tunnel for each test suite or build and tear it down at the end of your test.
STEP 1: Sauce Connect Client calls REST API to start a tunnel.
STEP 2: REST API initiates a request to system to create a new Tunnel VM.
STEP 3: REST API tells the Sauce Connect Client DNS name of the Tunnel VM.
STEP 4: Sauce Connect Client makes connection request to Tunnel VM using its DNS name.
At this point, the tunnel is established between the Sauce Connect Client and the Tunnel VM.
STEP 1: Selenium/Appium test code sends an HTTPS request to the VM or Real Device that was created for this test (for example,
STEP 2: Test VM or Device sends this request to Tunnel VM in order to access SUT.
STEP 3: Tunnel VM forwards this request to Sauce Connect client via the secure tunnel.
STEP 4: Sauce Connect Client forwards the request to Site Under Test (SUT).
STEP 5: Site Under Test returns response to Sauce Connect Client.
STEP 6: Sauce Connect client sends response to Tunnel VM via secure tunnel.
STEP 7: Tunnel VM sends response to Test VM.
STEP 8: Test VM sends results back to Selenium/Appium Test cloud.
Throughout the lifetime of a tunnel, Sauce Connect Client sends status information to Sauce Labs REST API.
Now that you're up and running with a Basic Sauce Connect Proxy Setup, we recommend reviewing the following topics: