Skip to content

kmissoumi/demo-python

Repository files navigation

Sauce Labs Devices

python Edition


🚀 Sign Up for a free trial at Sauce Labs ‼️
📄 Source python Repo and README
📄 Dynamic Device Allocation
📄 Selenium Python Course
📄 saucelabs Documentation Home
📄 saucelabs Knowledge Base
📄 saucelabs API Reference

 

Quick Start

  • pipenv Required
  • Set Environment Variables
    • SAUCE_USERNAME
    • SAUCE_ACCESS_KEY
  • Download Repo and Create virtualenv

 

# clone repo
git clone https://github.com/kmissoumi/demo-python.git && cd demo-python

# setup virtualenv
pipenv install

# enter virtualenv
pipenv shell

# optional info
python --version      # Python 3.9.9
pipenv --version      # pipenv, version 2021.11.23             

The test suite referenced below has (5) tests.

  • The format follows as this B<NN>_S<NN>_D<NN>_C<NN>_J<NN>
    • Where N is a number.
    • Where B is the build prefix.
    • Where S is for the suite, and N is the number of cycles run.
    • Where D is for the device, and N is the number of devices requested.
    • Where J is for jobs, and N is the number of jobs submitted.
# Test 01
#   Run the entire test suite, (5) tests, (1) cycle.
#   Spread the tests out over (1) device.
export BUILD_TAG="B01_S01_D01_J05"
pytest best_practice/mobile_native/android --dc=us

# Test 02
#   Run the entire test suite, (5) tests, , (1) cycle.
#   Spread the tests out over (5) devices.
export BUILD_TAG="B02_S01_D05_C01_J05"
pytest best_practice/mobile_native/android --dc=us -n5

Does a request for 5x devices result in 5x performance?

What if we don't use cacheId?

# Test 03
#   Run every test in the entire test suite, (5) times in a row, for (5) full cycles.
#   On the same (1) device.
export BUILD_TAG="B03_S05_D01_J25"
pytest best_practice/mobile_native/android --dc=us --count 5


# Test 04
#   Run each test in the suite (5) times in a row.
#   Spread the tests out over (5) devices.
#   Tests are submitted to the first allocated device that is available. 
export BUILD_TAG="B04_S10_D20_J25"
pytest best_practice/mobile_native/android --dc=us -n5 --count 5


# Test 05
#   Run the entire test suite, (5) tests, (10) full cycles
#   Spread the tests out over (10) devices.
export BUILD_TAG="B05_S10_D20_J50"
pytest best_practice/mobile_native/android --dc=us -n10 --count 10


Explore other plugins such as pytest-parallel.

export BUILD_TAG="ZZ_S01_W05_J05"`  
pytest best_practice/mobile_native/android --dc=us --workers 5`


Dynamic Device Allocation

  

Note: Only update the rdc_browser in best_practice/conftest.py

Suggestion: Only update one capability at a time for your first few reps.

Set the Device Type and/or Pool

  

Hint: Run multiple test suites on the same device with cacheId!

  


Example Capabilities

  

# specific device via id
caps = {
    'deviceName': 'iPhone_12_POC137',
    'platformName': 'iOS',
    'cacheId': 'yogi'
}

Hint: Find Device Id, Details, and Availability theEasyWay!

  

# any iPhone from my private device pool
caps = {
    'deviceName': 'iPhone.*',
    'platformName': 'iOS',
    'cacheId': 'booboo',
    'privateDevicesOnly': True
}

  

# any iOS 15.x phone from the public device pool
caps = {
    'deviceName': '.*',
    'platformName': 'iOS',
    'platformVersion': 15,
    'phoneOnly': True,
    'cacheId': 'cindy',
    'publicDevicesOnly': True
}

  

# any Android 10 phone or tablet 
caps = {
    'deviceName': '*',
    'platformName': 'Android',
    'platformVersion': 10,
    'cacheId': 'ranger'
}

  


References


Device Cleanup

Per Session Device Cleanup Steps

  • accounts and data cleared
  • default browser history and user data removed
  • non-default browsers uninstalled
  • network settings reset
  • device settings reset
  • app uninstalled
  • cached data deleted
  • device de-allocated

 

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors