Package: selpy
SelpySelpy 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.InstallationAdd this line to your application's requirements.txt file:selpy==<version>And then execute:pip3 install -r requirements.txtOr install it yourself as:pip3 install selpyUsageThis module is built to replace the library methods inSelpy-Pythonframework. 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 verifySelpu Python Documentationpage.Adding new methodsAdd all the new methods inside/selpy/path and add import the class inside__init__.pyfile in the same path so that the newly added class can be imported by using this module.Require and IncludeTo import this module use,import selpyTo import specific class in this module use,from selpy.driver import DriverDetailing the moduleDriverDriver file holds all the common actions that are executed by the driver. Initiate the driver by,driver = Driver()Thedriverwill hold the selenium webdriver object.For configuring the driver capabilities, one has to specify the details in the global_data.yml inSelpy-Python.LocatorThis 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
    @staticmethod
    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 allowselpyto 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'StoreThis 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.VariableThis 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 pytestBut, 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 toSelpy-Pythonframework insideTests/amazon.pyUpon running the tests in normal modepytestthe 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 inpytest_configuremethod (so that these path variables will be set on initiating the pytest).from selpy.store 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 pypiInstall the following dependenciespython3 -m pip install --user --upgrade setuptools wheelIn the root directory of your newly created module run,python3 setup.py sdist bdist_wheelThen add the username and password and upload to the pypi server,python3 -m twine upload -u <username> -p <password> --repository-url https://upload.pypi.org/legacy/ dist/* --verboseEnsure that you have deleted the old files from your dist directory.ContributingBug reports and pull requests are welcome on GitHub athttps://github.com/nareshnavinash/selpy/. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to theContributor Covenantcode of conduct.AuthorsNaresh SekarLicenseThe gem is available as open source under the terms of theGPL-3.0 License.Code of ConductEveryone interacting in the Teber project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow thecode of conduct.