Skip to content

How To ‐ Sauce Labs

NikolayStanoev edited this page Feb 22, 2017 · 3 revisions

Prerequisite

  • Create Sauce Labs account or use an existing one.
  • Login in that account and get the following information - username / access_key. You can get this information from Sauce Labs User Settings
  • Download Sauce Connect - this is a Sauce Labs executable which will make a tunnel between your machine and Sauce Labs environment. You can find more information for Sauce Connect (and download it) from here. Keep in mind that you will need different file to download depending on your OS from where you want to start Sauce Connect.
  • Start Sauce Connect - you can simply run the following command from bin folder of the downloaded zip file (just replace username / access+key with your values):
    sc -u username -k access_key

BrowserStack Access URL

You can use the code below which will return BrowserStack url (just replace username / access_key with real values):

    private String getSauceLabsHubUrl() {
        String user = "username";
        String key = "access_key";
        return "https://"+user+":"+key+"@ondemand.saucelabs.com:443/wd/hub";
    }

Prepare minimum capabilities for running the test

iOS example

    private DesiredCapabilities getSauceLabsiPhoneCapabilities(){
        DesiredCapabilities capabilities = DesiredCapabilities.iphone();
        capabilities.setCapability("appiumVersion", "1.6.3");
        capabilities.setCapability("deviceName","iPhone 7 Simulator");
        capabilities.setCapability("deviceOrientation", "portrait");
        capabilities.setCapability("platformVersion","10.0");
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("browserName", "Safari");
        return capabilities;
    }

Android example

    private DesiredCapabilities getSauceLabsAndroidCapabilities() {
        DesiredCapabilities capabilities = new DesiredCapabilities().android();
        capabilities.setCapability("appiumVersion", "1.5.3");
        capabilities.setCapability("deviceName","Google Nexus 7C Emulator");
        capabilities.setCapability("deviceOrientation", "portrait");
        capabilities.setCapability("browserName", "Browser");
        capabilities.setCapability("platformVersion", "4.4");
        capabilities.setCapability("platformName","Android");
        return capabilities;
    }

Notes

  • Sauce Labs documentation is really good and can give you a lot of insights about automated testing on mobile.
  • Before decide using Sauce Labs as your primary option check the following things (Pricing / iOS & Android OS Supported Versions for automated testing / Mobile Browser Version).

Useful Links