Skip to main content

NZME Test Automation Library

Project description

Skynet - Test Automation Library @ NZME

Build Status codecov

Features included:

  • A python3.6+ library to automate web apps and mobile apps across range of browsers and devices
  • Scripts to automate visual testing
  • Out of box integration with cloud testing (e.g. Sauce Labs)
  • Plugin to run REST api calls
  • Support for BDD scenarios and parallel execution run
  • Support for Mobile app testing, see Mobile app readme
  • Capture and manipulate HTTP traffic using browsermob-proxy

Install Skynet package:

Install from source.

    $ git clone <repo>
    $ cd skynet
    $ python install 

Setup instructions

Install pip, web browsers, Emulators

Run Tests

You can run all of the tests via tox in your local

    (skynet3-env) $ deactivate
    $ sudo apt install python-tox
    $ tox

For detailed run:

Setup test env

    $ source skynet3-env/bin/activate
    (skynet3-env) $ ./ start
    (skynet3-env) $ curl -sSL http://localhost:4444/wd/hub/status | jq .value.ready | grep true

Run tests (with coverage)

    (skynet3-env) $ py.test -vvv --cov=nzme_skynet test     

To run all the tests in parallel

    (skynet3-env) $ py.test -n <no_of_parallel_processes> test

To run individual tests

    (skynet3-env) $ py.text -q test/<>

Teardown test env

    (skynet3-env) $ ./ stop

BDD Test Setup

Test setup is managed in a default configuration file testsetup.ini which can be overridden on commandline.

#------- Desktop Platforms -------#
#- Generic Selenium/Cloud capabilities -#
capabilities =  {
                "browserName": "chrome",
                "version": "ANY",
                "platform": "ANY",
                "goog:chromeOptions" : {
                    "args": ["--disable-gpu"],
                    "extensions": [],
                    "prefs": {}
#- Framework specific capabilities -#
highlight = true
resolution = maximum # e.g. maximum, 1126x830
headless = false
mobileEmulation = # e.g. iPhone X, Galaxy S5 etc

#------- Mobile Platforms -------#
#- Generic Appium capabilities -#
capabilities = {
                "platformName": "Android",
                "platformVersion": "8.1",
                "deviceName": "Device 01"
                "udid": "emulator-5554",
                "appPackage": "appPackage",
                "appActivity": "appActivity",
                "app": "/path/to/"

capabilities = {
                "platformName": "iOS",
                "platformVersion": "11.0",
                "deviceName": "iPhone 7",
                "automationName": "XCUITest",
                "app": "/path/to/"

#------- Environmental -------#
#- Framework specific capabilities -#

The capabilities key is "free-form" selenium/appium/cloud capabilities key-value pair that is passed on to the framework.

For desktop tests, one can remove the sections [Android] and [IOS], similarly for mobile tests one can remove the section [BROWSER]. The section [ENVIRONMENT] is however mandatory.

One can also have separate "testsetup.ini" files for different runs e.g. testsetup_browserstack.ini with browserstack specific capabilities only, or testsetup_android.ini for android tests. This custom .ini can be passed as a command line parameter for behave tests.

(skynet3-env) $ behave -D configfile=testsetup_browserstack.ini --tags=@p1
(skynet3-env) $ behave -D configfile=testsetup_android.ini --tags=@android-app --tags=@p1

The capabilities and environment key value options can also be updated on the commandline.

(skynet3-env) $ behave -D browserName=firefox -D version=65.0 -D local=true -D headless=true --tags=@p1

BDD Parallel Tests Run utility

Allows running BDD tests in parallel, hence saving on execution time.

(skynet3-env) $ nzme-behave-parallel -h
usage: Run behave in parallel mode for scenarios [-h] [--processes PROCESSES]
                                                 [--tags TAGS]
                                                 [--define DEFINE]

optional arguments:
  -h, --help            show this help message and exit
  --processes PROCESSES, -p PROCESSES
                        Maximum number of processes. Default = 5
  --tags TAGS, -t TAGS  specify behave tags to run
  --define DEFINE, -D DEFINE
                        Define user-specific data for the config.userdata
                        dictionary. Example: -D foo=bar to store it in

E.g. to run 4 scenarios in parallel based on tags and override test configuration

(skynet3-env) $ nzme-behave-parallel -p 4 -t prod -D local=false -D browserName=firefox

Supported Tags for use with Behave

We use Behave as our BDD Runner, while skynet does not require you to use it, it does have some extra support built in. You can tag the scenarios/feature files with the following platform tags to initialise appropriate driver.

If no platform tag is specified, then the default platform of web/browser is used.


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for nzme-skynet, version 0.5.0
Filename, size File type Python version Upload date Hashes
Filename, size nzme-skynet-0.5.0.tar.gz (38.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page