-1

How do you setup Saucelabs to work in a team, viewing shared tests, and sharing a sauce connect tunnel

-Chris Toews

Chris Toews
  • 119
  • 1
  • 3

1 Answers1

1

So I just spent a few hours getting this to work, and I didn't find any resource that listed all this in one place. So I figured I would document how to get Saucelabs working in a team environment.

Here are my assumptions:

  • You are working in Python (Most of the concepts will apply cross-language)
  • You have a paid saucelabs account
  • You have a main account, and sub accounts
  • You want a "sauce connect" tunnel to be able to be used by entire team
  • You want the entire team to have access to view automated tests

Here is how I setup my environment:

Share the Tunnel

Setup sauce connect tunnel with the main account id and key, giving it a name and flagging it as a shared tunnel

sc -u main_account_id -k your_api_key --shared-tunnel  --tunnel-identifier your_tunnel_name

This makes the tunnel on the main_account_id, names the tunnel, and shares it across your team

Run tests from the bulk_user

I setup a saucelabs user called "bulktests" just for automated tests. I wanted a generic account to run automated tests in. The main user account is not an option for your bulk tests because if you run your tests from the main user account, nobody except the main user will be able to see them. Tests can only be shared among sibling accounts. Once I had the bulktests user, I connected my sauce client in Python using their ID and api key.

self.driver = webdriver.Remote(
                command_executor='http://' + bulkuser + ':' + bulk_user_api_key + '@ondemand.saucelabs.com:80/wd/hub',
                desired_capabilities=desired_capabilities_dictionary) 

Use the shared Tunnel

I had to give the desired capabilities that I wanted the shared tunnel ID. I also had to give the desired capability that it was a "parentTunnel"

 desired_cap = {
            'platform': "Windows 7",
            'browserName': "firefox",
            'name': "dummyTest",
            "parentTunnel":"mainAccountID",
            "tunnelIdentifier": "your_tunnel_name"
        }

Make Test available to Team

The saucelabs documentation leads you to believe that setting sharing to team can be done in the desired capabilities. I have found this to not work in my testing. Here is how I was able to share tests. I made a sauce_client object (which I use at the end of my test to push results to saucelabs), and I set public = team there

self.sauce_client = SauceClient(sauceuser, saucecode)
        # sauceuser and saucecode defined earlier,  this is the bulk_user to run my automated tests
        self.driver = webdriver.Remote(
                command_executor='http://' + sauceuser + ':' + saucecode + '@ondemand.saucelabs.com:80/wd/hub',
                desired_capabilities=desired_cap)
        self.sauce_client.jobs.update_job(self.driver.session_id, public="team")

Team members view results

Once each test completes, team members can go to their Archive page, and then you have to search for tests to see the shared tests. The Archive page by default does not show you all the tests, you must search for test for the bulk user created earlier

Chris Toews
  • 119
  • 1
  • 3