The Sauce Labs Cookbook

Sauce Headless

Front End Performance Testing

Analytics

External Resources

More Info


Page tree
Skip to end of metadata
Go to start of metadata

You can also clone this script directly from GitHub.

Authentication over HTTP instead of HTTPS

Unlike other languages, the Selenium bindings for Python don't support connecting over HTTPS. In the code example, you can see that connection to Sauce Labs is over HTTP, while the code examples for other languages are over HTTPS. This issue is documented, along with a proposed fix, in the Selenium issue tracker: https://github.com/SeleniumHQ/selenium/issues/420

import os

from appium import webdriver


caps = {
        'appiumVersion':    '1.9.1',
        'browserName':      'chrome',
        'platformName':     'Android',
        'deviceName':       'Android GoogleAPI Emulator',
        'platformVersion':  '9.0',
        'deviceOrientation':'portrait',
        'name': 'simple-android',
        # you can set a destination for an app to load on the emulator 
        # 'app': 'http://appium.s3.amazonaws.com/ContactManager.apk'
}

user = os.environ.get('SAUCE_USERNAME', 'my-username')
access_key = os.environ.get('SAUCE_ACCESS_KEY', 'my-key')

sauce_url = "https://{}:{}@ondemand.saucelabs.com/wd/hub/".format(user,access_key)

driver = webdriver.Remote(sauce_url, desired_capabilities=caps)

# appium application logic here

driver.quit()