Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jsfehler/stere
A library for writing Page Objects, designed to work on top of an existing automation library.
https://github.com/jsfehler/stere
appium automation page-object page-object-model pageobject python python3 python36 python37 python38 python39 selenium splinter
Last synced: 19 days ago
JSON representation
A library for writing Page Objects, designed to work on top of an existing automation library.
- Host: GitHub
- URL: https://github.com/jsfehler/stere
- Owner: jsfehler
- License: mit
- Created: 2017-12-06T12:44:37.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-24T07:39:09.000Z (about 2 months ago)
- Last Synced: 2024-10-11T15:12:45.036Z (about 1 month ago)
- Topics: appium, automation, page-object, page-object-model, pageobject, python, python3, python36, python37, python38, python39, selenium, splinter
- Language: Python
- Homepage:
- Size: 2.24 MB
- Stars: 24
- Watchers: 4
- Forks: 8
- Open Issues: 16
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
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
:alt: Updates
:target: https://pyup.io/repos/github/jsfehler/stere.. image:: https://github.com/jsfehler/stere/workflows/CI/badge.svg
:target: https://github.com/jsfehler/stere/actions/workflows/run_tests.yml
:alt: Build status.. image:: https://codecov.io/gh/jsfehler/stere/branch/master/graph/badge.svg?token=C1vfu8YgWn
:target: https://codecov.io/gh/jsfehler/stere.. image:: https://saucelabs.com/buildstatus/jsfehler
:target: https://saucelabs.com/u/jsfehlerStere 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 `_ and `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, Textclass 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 `_ with two `Fields `_ 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() `_ method.The links to other products are represented as a `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