stere


Namestere JSON
Version 0.22.0 PyPI version JSON
download
home_pagehttps://github.com/jsfehler/stere
SummaryA nice way of implementing the Page Object pattern.
upload_time2021-01-14 02:16:29
maintainer
docs_urlNone
authorJoshua Fehler
requires_python
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Stere
=====


.. image:: https://img.shields.io/pypi/v/stere.svg
    :target: https://pypi.org/project/stere
    :alt: PyPI

.. image:: https://img.shields.io/pypi/pyversions/stere.svg
    :alt: PyPI - Python Version
    :target: https://github.com/jsfehler/stere

.. image:: https://img.shields.io/github/license/jsfehler/stere.svg
    :alt: GitHub
    :target: https://github.com/jsfehler/stere/blob/master/LICENSE

.. image:: https://pyup.io/repos/github/jsfehler/stere/shield.svg
    :target: https://pyup.io/repos/github/jsfehler/stere
    :alt: Updates

.. image:: https://travis-ci.org/jsfehler/stere.svg?branch=master
    :target: https://travis-ci.org/jsfehler/stere

.. image:: https://coveralls.io/repos/github/jsfehler/stere/badge.svg?branch=master
    :target: https://coveralls.io/github/jsfehler/stere?branch=master

.. image:: https://api.codacy.com/project/badge/Grade/e791ab09e14c4483943a26a2fd180577
    :target: https://www.codacy.com/app/joshua-fehler_2/stere?utm_source=github.com&utm_medium=referral&utm_content=jsfehler/stere&utm_campaign=Badge_Grade

.. image:: https://saucelabs.com/buildstatus/jsfehler
    :target: https://saucelabs.com/u/jsfehler

Stere is a library for writing Page Objects, designed to work on top of an existing automation library.


Design Philosophy
-----------------

Many implementations of the Page Object model focus on removing the duplication of element locators inside tests.
Stere goes one step further, offering a complete wrapper over the code that drives automation.

The goals of this project are to:

1 - Eliminate implementation code in test functions. Tests should read like a description of behaviour, not Selenium commands.

2 - Reduce the need for hand-written helper methods in Page Objects. Common actions should have universal solutions.

3 - Provide a simple pattern for writing maintainable Page Objects.

No automation abilities are built directly into the project; it completely relies on being hooked into other libraries.
However, implementations using `Splinter <https://github.com/cobrateam/splinter>`_ and `Appium <https://github.com/appium/appium>`_ are available out of the box.


Documentation
-------------

https://stere.readthedocs.io/en/latest/


Basic Usage
-----------

Fundamentally, a Page Object is just a Python class.

A minimal Stere Page Object should:

1 - Subclass the Page class

2 - Declare Fields and Areas in the __init__ method

As an example, here's the home page for Wikipedia:

.. code-block:: python

    from stere import Page
    from stere.areas import Area, RepeatingArea
    from stere.fields import Button, Input, Link, Root, Text


    class WikipediaHome(Page):
        def __init__(self):
            self.search_form = Area(
                query=Input('id', 'searchInput'),
                submit=Button('xpath', '//*[@id="search-form"]/fieldset/button')
            )

            self.other_projects = RepeatingArea(
                root=Root('xpath', '//*[@class="other-project"]'),
                title=Link('xpath', '//*[@class="other-project-title"]'),
                tagline=Text('xpath', '//*[@class="other-project-tagline"]')
            )

The search form is represented as an `Area <https://stere.readthedocs.io/en/latest/area.html>`_ with two `Fields <https://stere.readthedocs.io/en/latest/field.html>`_ inside it.

A Field represents a single item, while an Area represents a unique collection of Fields.

The query and submit Fields didn't have to be placed inside an Area.
However, doing so allows you to use Area's `perform() <https://stere.readthedocs.io/en/latest/area.html#stere.areas.Area.perform>`_ method.

The links to other products are represented as a `RepeatingArea <https://stere.readthedocs.io/en/latest/area.html#stere.areas.RepeatingArea>`_ .
A RepeatingArea represents a non-unique collection of Fields on the page.
Using the root argument as the non-unique selector, RepeatingArea will find all instances of said root,
then build the appropriate number of Areas with all the other Fields inside.

It's just as valid to declare each of the other products as a separate Area
one at a time, like so:

.. code-block:: python

    self.commons = Area(
        root=Root('xpath', '//*[@class="other-project"][1]'),
        title=Link('xpath', '//*[@class="other-project-title"]'),
        tagline=Text('xpath', '//*[@class="other-project-tagline"]')
    )

    self.wikivoyage = Area(
        root=Root('xpath', '//*[@class="other-project"][2]'),
        title=Link('xpath', '//*[@class="other-project-title"]'),
        tagline=Text('xpath', '//*[@class="other-project-tagline"]')
    )

Which style you pick depends entirely on how you want to model the page.
RepeatingArea does the most good with collections where the number of areas and/or the contents of the areas
can't be predicted, such as inventory lists.

Using a Page Object in a test can be done like so:

.. code-block:: python

    def test_search_wikipedia():
        home = WikipediaHome()
        home.search_form.perform('kittens')


License
-------

Distributed under the terms of the `MIT`_ license, "Stere" is free and open source software


Issues
------

If you encounter any problems, please `file an issue`_ along with a detailed description.


Thanks
------

Cross-browser Testing Platform and Open Source <3 Provided by `Sauce Labs`_


.. _`file an issue`: https://github.com/jsfehler/stere/issues
.. _`MIT`: http://opensource.org/licenses/MIT
.. _`Sauce labs`: https://saucelabs.com



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/jsfehler/stere",
    "name": "stere",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Joshua Fehler",
    "author_email": "jsfehler@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0c/0a/feb2caeaf4feb439986480653fc40ee069cc67c7252fbef09457caba4c11/stere-0.22.0.tar.gz",
    "platform": "",
    "description": "Stere\n=====\n\n\n.. image:: https://img.shields.io/pypi/v/stere.svg\n    :target: https://pypi.org/project/stere\n    :alt: PyPI\n\n.. image:: https://img.shields.io/pypi/pyversions/stere.svg\n    :alt: PyPI - Python Version\n    :target: https://github.com/jsfehler/stere\n\n.. image:: https://img.shields.io/github/license/jsfehler/stere.svg\n    :alt: GitHub\n    :target: https://github.com/jsfehler/stere/blob/master/LICENSE\n\n.. image:: https://pyup.io/repos/github/jsfehler/stere/shield.svg\n    :target: https://pyup.io/repos/github/jsfehler/stere\n    :alt: Updates\n\n.. image:: https://travis-ci.org/jsfehler/stere.svg?branch=master\n    :target: https://travis-ci.org/jsfehler/stere\n\n.. image:: https://coveralls.io/repos/github/jsfehler/stere/badge.svg?branch=master\n    :target: https://coveralls.io/github/jsfehler/stere?branch=master\n\n.. image:: https://api.codacy.com/project/badge/Grade/e791ab09e14c4483943a26a2fd180577\n    :target: https://www.codacy.com/app/joshua-fehler_2/stere?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=jsfehler/stere&amp;utm_campaign=Badge_Grade\n\n.. image:: https://saucelabs.com/buildstatus/jsfehler\n    :target: https://saucelabs.com/u/jsfehler\n\nStere is a library for writing Page Objects, designed to work on top of an existing automation library.\n\n\nDesign Philosophy\n-----------------\n\nMany implementations of the Page Object model focus on removing the duplication of element locators inside tests.\nStere goes one step further, offering a complete wrapper over the code that drives automation.\n\nThe goals of this project are to:\n\n1 - Eliminate implementation code in test functions. Tests should read like a description of behaviour, not Selenium commands.\n\n2 - Reduce the need for hand-written helper methods in Page Objects. Common actions should have universal solutions.\n\n3 - Provide a simple pattern for writing maintainable Page Objects.\n\nNo automation abilities are built directly into the project; it completely relies on being hooked into other libraries.\nHowever, implementations using `Splinter <https://github.com/cobrateam/splinter>`_ and `Appium <https://github.com/appium/appium>`_ are available out of the box.\n\n\nDocumentation\n-------------\n\nhttps://stere.readthedocs.io/en/latest/\n\n\nBasic Usage\n-----------\n\nFundamentally, a Page Object is just a Python class.\n\nA minimal Stere Page Object should:\n\n1 - Subclass the Page class\n\n2 - Declare Fields and Areas in the __init__ method\n\nAs an example, here's the home page for Wikipedia:\n\n.. code-block:: python\n\n    from stere import Page\n    from stere.areas import Area, RepeatingArea\n    from stere.fields import Button, Input, Link, Root, Text\n\n\n    class WikipediaHome(Page):\n        def __init__(self):\n            self.search_form = Area(\n                query=Input('id', 'searchInput'),\n                submit=Button('xpath', '//*[@id=\"search-form\"]/fieldset/button')\n            )\n\n            self.other_projects = RepeatingArea(\n                root=Root('xpath', '//*[@class=\"other-project\"]'),\n                title=Link('xpath', '//*[@class=\"other-project-title\"]'),\n                tagline=Text('xpath', '//*[@class=\"other-project-tagline\"]')\n            )\n\nThe search form is represented as an `Area <https://stere.readthedocs.io/en/latest/area.html>`_ with two `Fields <https://stere.readthedocs.io/en/latest/field.html>`_ inside it.\n\nA Field represents a single item, while an Area represents a unique collection of Fields.\n\nThe query and submit Fields didn't have to be placed inside an Area.\nHowever, doing so allows you to use Area's `perform() <https://stere.readthedocs.io/en/latest/area.html#stere.areas.Area.perform>`_ method.\n\nThe links to other products are represented as a `RepeatingArea <https://stere.readthedocs.io/en/latest/area.html#stere.areas.RepeatingArea>`_ .\nA RepeatingArea represents a non-unique collection of Fields on the page.\nUsing the root argument as the non-unique selector, RepeatingArea will find all instances of said root,\nthen build the appropriate number of Areas with all the other Fields inside.\n\nIt's just as valid to declare each of the other products as a separate Area\none at a time, like so:\n\n.. code-block:: python\n\n    self.commons = Area(\n        root=Root('xpath', '//*[@class=\"other-project\"][1]'),\n        title=Link('xpath', '//*[@class=\"other-project-title\"]'),\n        tagline=Text('xpath', '//*[@class=\"other-project-tagline\"]')\n    )\n\n    self.wikivoyage = Area(\n        root=Root('xpath', '//*[@class=\"other-project\"][2]'),\n        title=Link('xpath', '//*[@class=\"other-project-title\"]'),\n        tagline=Text('xpath', '//*[@class=\"other-project-tagline\"]')\n    )\n\nWhich style you pick depends entirely on how you want to model the page.\nRepeatingArea does the most good with collections where the number of areas and/or the contents of the areas\ncan't be predicted, such as inventory lists.\n\nUsing a Page Object in a test can be done like so:\n\n.. code-block:: python\n\n    def test_search_wikipedia():\n        home = WikipediaHome()\n        home.search_form.perform('kittens')\n\n\nLicense\n-------\n\nDistributed under the terms of the `MIT`_ license, \"Stere\" is free and open source software\n\n\nIssues\n------\n\nIf you encounter any problems, please `file an issue`_ along with a detailed description.\n\n\nThanks\n------\n\nCross-browser Testing Platform and Open Source <3 Provided by `Sauce Labs`_\n\n\n.. _`file an issue`: https://github.com/jsfehler/stere/issues\n.. _`MIT`: http://opensource.org/licenses/MIT\n.. _`Sauce labs`: https://saucelabs.com\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A nice way of implementing the Page Object pattern.",
    "version": "0.22.0",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "641b46414b76fd9c4fbdea21acb4eea6",
                "sha256": "99c3cf26f0e79be2ef202727f5e3ee8c7897e1563ba1ebe1a76248542f3c6fe0"
            },
            "downloads": -1,
            "filename": "stere-0.22.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "641b46414b76fd9c4fbdea21acb4eea6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 27401,
            "upload_time": "2021-01-14T02:16:27",
            "upload_time_iso_8601": "2021-01-14T02:16:27.632003Z",
            "url": "https://files.pythonhosted.org/packages/32/05/83a88b9ea14d7da1dcaa7c95daf34a4e921a7b1c429c76aee4e8928b8e32/stere-0.22.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "287446adb155dad5a08f19d04b083f3b",
                "sha256": "036cee14ddb17df35ddfaea186da5d833ac78e560adcb3e3d43acba39746bc79"
            },
            "downloads": -1,
            "filename": "stere-0.22.0.tar.gz",
            "has_sig": false,
            "md5_digest": "287446adb155dad5a08f19d04b083f3b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 18886,
            "upload_time": "2021-01-14T02:16:29",
            "upload_time_iso_8601": "2021-01-14T02:16:29.176009Z",
            "url": "https://files.pythonhosted.org/packages/0c/0a/feb2caeaf4feb439986480653fc40ee069cc67c7252fbef09457caba4c11/stere-0.22.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-01-14 02:16:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": null,
    "github_project": "jsfehler",
    "error": "Could not fetch GitHub repository",
    "lcname": "stere"
}
        
Elapsed time: 0.24059s