py-selenium-browser

Decorators for provisioning tests with remote webdrivers.

View the Project on GitHub

py-selenium-browser

build PyPI version codecov

Decorators for provisioning tests with selenium remote webdrivers.

For an all inclusive selenium framework check out py-component-controller!

About

py-selenium-browser is a very simple project based off of nose_parammeterzed. This project provides very simple and easily configurable decorators to parameterize individual tests to run against multiple browser configurations against your stack.

Usage

py-selenium-browser supports both Python 2.7 and 3.6 and can be installed with pip like so,

pip install pysbr

Import Decorators and Configure from pysbr to get started,

import os
from selenium import webdriver
from unittest import TestCase

from pysbr import Configure, Decorators


Configure.platforms(name='chrome', platforms=['WIN10'])
Configure.capabilities(name='edge', capabilities={
    'version': '5'
})
Configure.profile(name='safari', profile=None)
Configure.enable(name='firefox')
Configure.disable(name='opera')

COMMAND_EXECUTOR = os.environ.get('COMMAND_EXECUTOR')


class SampleTest(TestCase):

    @Decorators.browsers()
    def test_login(self, capabilities, profile):
        browser = webdriver.Remote(
            COMMAND_EXECUTOR, capabilities, profile)
        ...
        browser.stop_client()
        
    @Decorators.browser(name='chrome', platform='WIN10')
    def test_register(self, capabilities, profile):
        ...
        
    @Decorators.random_browser()
    def test_logout(self, capabilities, profile):
        ...

This project supports the Chrome, Firefox, Edge, Safari, and Opera browsers by default – but other browsers can be defined like so,

from pysbr.constants import BROWSERS

BROWSERS.ANDROID = BROWSERS.BROWSER(
    name, platforms, capabilities=None, profile=None)
BROWSERS.browsers.append(BROWSERS.ANDROID)

All browsers also disabled by default, so be sure to enable them prior to use with the decorators.

Testing

All module related unit tests are in the tests subdirectory.

To setup your environment run make setup. To run the test suite, use make test.

Requirements:

Contributors

Contributing guidelines are as follows,


Copyright (c) 2017 John Nolette Licensed under the MIT license.