Skip to main content

Package to hold driver and locator methods for selenium

Project description


Selpy module is to have all the common methods that will be used in functional UI automation in Page Object Model. Selpy also powered to have snapshot feature that will save the data from UI to a file if needed. This in turn reduces the test data maintenance efforts.

License: GPL v3 Made with Python StackOverflow Contributions Welcome email me

alt text


Add this line to your application's requirements.txt file:


And then execute:

pip3 install -r requirements.txt

Or install it yourself as:

pip3 install selpy


This module is built to replace the library methods in Selpy-Python framework. This allows us to share the methods among different teams and completely ignore the repetitive work. For more details on Page object model for functional UI automation verify Selpu Python Documentation page.

Adding new methods

Add all the new methods inside /selpy/ path and add import the class inside file in the same path so that the newly added class can be imported by using this module.

Require and Include

To import this module use,

import selpy

To import specific class in this module use,

from selpy.driver import Driver

Detailing the module


Driver file holds all the common actions that are executed by the driver. Initiate the driver by,

driver = Driver()

The driver will hold the selenium webdriver object.

For configuring the driver capabilities, one has to specify the details in the global_data.yml in Selpy-Python.


This class is to declare the selenium locators in Page Object Model. You can declare the locators as follows,

class AmazonHomePageLocator:
    # Static locators
    amazon_logo = Locator("css selector", "div#nav-logo a[aria-label='Amazon']")
    amazon_search_categories = Locator("css selector", "div.nav-search-scope select.nav-search-dropdown")

    def __init__(self):
        print("Locators for Amazon home page")

    # Dynamic locators
    def amazon_search_category_list(string):
        return Locator("xpath", "//select[contains(@class,'nav-search-dropdown')]//option[text()='%s']" % string)

To use the Locator method we need to pass the type of locator and the actual locator element. Type of locator has to be mentioned in the following way to allow selpy to process the locator.

CSS - 'css selector'
XPATH - 'xpath'
ID - 'id'
NAME - 'name'
LINK TEXT - 'link text'
PARTIAL LINK TEXT - 'partial link text'
TAG NAME - 'tag name'
CLASS NAME - 'class name'


This class is to store the run time configurations for this module. Kind of a memcached or redis for our framework. Centralized run time data which are needed by other modules are being stored here and retrived by other modules.


This is where the actual snap feature logic is present. In order to save the UI data in to the dynamic file one has to run the tests with,

snap=1 pytest

But, only this will not ensure the data is getting saved in to dynamic file. One has to script their automation code in such a way that snap feature is supported. For example one can look in to Selpy-Python framework inside Tests/

Upon running the tests in normal mode pytest the dynamic data will not be overridden rather it will assert the data present in UI with the dynamic data file.

To get this feature running smoothly and to access the variables in smoother way, one has to configure the following params in their framework in pytest_configure method (so that these path variables will be set on initiating the pytest).

from import Store

def pytest_configure(config):
    # Configuring the selpy with data path location
    Store.global_data_path = os.path.dirname(os.path.abspath(__file__)).replace("/Tests", "") + '/Data/GlobalData/global_data.yml'
    Store.static_data_path = os.path.dirname(os.path.abspath(__file__)).replace("/Tests", "") + '/Data/TestData/'
    Store.dynamic_data_path = os.path.dirname(os.path.abspath(__file__)).replace("/Tests", "") + '/Data/DynamicData/'

To publish a module in pypi

  1. Install the following dependencies
python3 -m pip install --user --upgrade setuptools wheel
  1. In the root directory of your newly created module run,
python3 sdist bdist_wheel
  1. Then add the username and password and upload to the pypi server,
python3 -m twine upload -u <username> -p <password> --repository-url dist/* --verbose

Ensure that you have deleted the old files from your dist directory.


Bug reports and pull requests are welcome on GitHub at This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.



The gem is available as open source under the terms of the GPL-3.0 License.

Code of Conduct

Everyone interacting in the Teber project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

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 selpy, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size selpy-0.1.1-py3-none-any.whl (36.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size selpy-0.1.1.tar.gz (8.0 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page