navmazing


Namenavmazing JSON
Version 1.2.2 PyPI version JSON
download
home_page
SummaryA simple navigation framework
upload_time2023-12-04 19:12:05
maintainer
docs_urlNone
author
requires_python>=3.8
license
keywords selenium navigation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. image:: https://travis-ci.org/RedHatQE/navmazing.svg
   :scale: 50 %
   :alt: Build Status
   :align: left
   :target: https://travis-ci.org/RedHatQE/navmazing
.. image:: https://coveralls.io/repos/RedHatQE/navmazing/badge.svg?branch=master&service=github
   :scale: 50 %
   :alt: Coverage Status
   :align: left
   :target: https://coveralls.io/github/RedHatQE/navmazing?branch=master

navmazing
=========

Introduction
------------

Simple navigation framework supporting complex designs

Design
------

navmazing is based around a number of navigation steps which subclass the NavigateStep object. These step objects have a relationship by defining a prerequisite method which can go to the previous step if it is determined that we are not current on the requested step. This chaining of steps starting at a first and visiting all the prerequisites in the chain until they are resolved constitutes a complete navigation.

Usage
-----

An example is below. This creates a simple class modelling some Provider object that has three destinations or pages in the UI, a **New** page, a **Details** page and an **All** page. The **New** page is where a new Provider would be added, and the **All** page is where you could view a list of all of them. To get to the **New** page, you must first visit the **All** page. The **Details** page is where a specific provider would be displayed. In the example below you can see that we model some very simple steps and register them to the class.

.. code-block:: python

  from navmazing import Navigate, NavigateStep, NavigateToSibling

  navigator = Navigate()

  class Provider(object):
      def __init__(self, name):
          self.name = name

  @navigator.register(Provider, 'Details')
  class ProviderDetails(NavigateStep):
      prerequisite = NavigateToSibling('All')

      def step(self):
          click(self.obj.name)

  @navigator.register(Provider, 'New')
  class AddANewProvider(NavigateStep):
      prerequisite = NavigateToSibling('All')

      def step(self):
          click('Add New Button')

  @navigator.register(Provider, 'All')
  class ShowAllProviders(NavigateStep):
      def am_i_here(self):
          return check_if_i_am_already_on_page()

      def step(self):
          click('All button')

The class ``ShowAllProviders`` represents the step of getting to the **All** page. This class has two methods, ``am_i_here()`` and ``step()``. The ``step()`` method describes how we should perform the step of getting to the **All** page. It is assumed in this particular UI that the *All button* is always visible. The ``am_i_here()`` method is a way to query to see if we are already on this page. This is used to shortcut navigation if it can be determined that we are already on a page that we have requested to visit.

The class ``AddANewProvider`` represents the step of getting to the **New** page. This class has an attribute and a method. The ``prerequisite`` is actually a python descriptor. It uses the ``NavigateToSibling`` helper to navigate to the **All** destination on the same object that it has been requested to visit the **New** page on. One could simply make ``prerequisite`` a function that calls ``navigate_to`` with ``self.obj`` and the ``All`` destination. However the helper is much nicer and makes defining prerequisite steps a little more cleaner.

The class ``ProviderDetails`` represents the step of getting to a specific providers page, its **Details** page. This class is the same as the ``AddANewProvider`` class in that it first requires the All button to be pressed. Notice in the ``step()`` method, that there is a reference to ``self.obj``. This object is the object that is passed to navigation step as can be seen below. In the example below this object is called ``prov``.

.. code-block:: python

  # Non helper method
  def prerequisite(self):
      navigator.navigate(self.obj, 'All')

  # Using helper method
  prerequisite = NavigateToSibling('All')

To use the code above, one would instantiate a Provider object and then use the navigate method like so:

.. code-block:: python


  prov = Provider('name')
  navigator.navigate(prov, 'Details')

Navigation Helpers
------------------

navmazing has a few helpers to make prerequisites easier to define

* ``NavigateToSibling`` - Navigates to a destination that is registered to the same object as the current request.
* ``NavigateToAttribute`` - Navigates to a destination that is registered to an attribute of the same object as the current request. This is useful if there is some kind of hierarchy to your objects and you wish to navigate to a step that is registered against an attribute rather than the object itself
* ``NavigateToObject`` - Navigates to a destination that is registered to the supplied object, it could be argued that NavigateToAttribute could be implemented with a NavigateToObject call, by simply offering the attribute object as the object. It feels more dynamic and cleaner to use NavigateToAttribute in these cases, there the attribute is a string that is looked up, rather than an object which is static.

Flowchart
---------

The diagram below shows the flowchart of the process of resolving a navigation using the stock navmazing library. As the methods are overridable, the flow can be altered, but should suffice for most usages.

.. image:: https://github.com/psav/navmazing/raw/master/flowchart.png

Advanced Usage
--------------

navmazing also allows parameters to be passed at the navigate call. This means you can allow for some level of dynamic nature or choice in your navigation destinations. Let's say for example you have a step that usually works one way, but there are certain times when you need to override that behaviour and make it work a different way.

.. code-block:: python

  @navigator.register(Provider, 'Details')
  class ProviderDetails(NavigateStep)
      prerequisite = NavigateToSibling('All')

      def step(self, active=True):
          if choice:
              click(self.obj.name)
          else:
              click(self.obj.name + " - inactive")

  # Call by default
  navigate(obj, 'Details')

  # Call, passing in a parameter for choice
  navigate(obj, 'Details', active=False)

In the example above, passing the ``active`` parameter changes the behaviour of the step.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "navmazing",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Ronny Pfannschmidt <rpfannsc@redhat.com>",
    "keywords": "selenium,navigation",
    "author": "",
    "author_email": "Peter Savage <psavage@redhat.com>",
    "download_url": "https://files.pythonhosted.org/packages/03/4b/1ff69daaa04494f199e617dcbe8544842741e91840bbd9575b8e60151322/navmazing-1.2.2.tar.gz",
    "platform": null,
    "description": ".. image:: https://travis-ci.org/RedHatQE/navmazing.svg\n   :scale: 50 %\n   :alt: Build Status\n   :align: left\n   :target: https://travis-ci.org/RedHatQE/navmazing\n.. image:: https://coveralls.io/repos/RedHatQE/navmazing/badge.svg?branch=master&service=github\n   :scale: 50 %\n   :alt: Coverage Status\n   :align: left\n   :target: https://coveralls.io/github/RedHatQE/navmazing?branch=master\n\nnavmazing\n=========\n\nIntroduction\n------------\n\nSimple navigation framework supporting complex designs\n\nDesign\n------\n\nnavmazing is based around a number of navigation steps which subclass the NavigateStep object. These step objects have a relationship by defining a prerequisite method which can go to the previous step if it is determined that we are not current on the requested step. This chaining of steps starting at a first and visiting all the prerequisites in the chain until they are resolved constitutes a complete navigation.\n\nUsage\n-----\n\nAn example is below. This creates a simple class modelling some Provider object that has three destinations or pages in the UI, a **New** page, a **Details** page and an **All** page. The **New** page is where a new Provider would be added, and the **All** page is where you could view a list of all of them. To get to the **New** page, you must first visit the **All** page. The **Details** page is where a specific provider would be displayed. In the example below you can see that we model some very simple steps and register them to the class.\n\n.. code-block:: python\n\n  from navmazing import Navigate, NavigateStep, NavigateToSibling\n\n  navigator = Navigate()\n\n  class Provider(object):\n      def __init__(self, name):\n          self.name = name\n\n  @navigator.register(Provider, 'Details')\n  class ProviderDetails(NavigateStep):\n      prerequisite = NavigateToSibling('All')\n\n      def step(self):\n          click(self.obj.name)\n\n  @navigator.register(Provider, 'New')\n  class AddANewProvider(NavigateStep):\n      prerequisite = NavigateToSibling('All')\n\n      def step(self):\n          click('Add New Button')\n\n  @navigator.register(Provider, 'All')\n  class ShowAllProviders(NavigateStep):\n      def am_i_here(self):\n          return check_if_i_am_already_on_page()\n\n      def step(self):\n          click('All button')\n\nThe class ``ShowAllProviders`` represents the step of getting to the **All** page. This class has two methods, ``am_i_here()`` and ``step()``. The ``step()`` method describes how we should perform the step of getting to the **All** page. It is assumed in this particular UI that the *All button* is always visible. The ``am_i_here()`` method is a way to query to see if we are already on this page. This is used to shortcut navigation if it can be determined that we are already on a page that we have requested to visit.\n\nThe class ``AddANewProvider`` represents the step of getting to the **New** page. This class has an attribute and a method. The ``prerequisite`` is actually a python descriptor. It uses the ``NavigateToSibling`` helper to navigate to the **All** destination on the same object that it has been requested to visit the **New** page on. One could simply make ``prerequisite`` a function that calls ``navigate_to`` with ``self.obj`` and the ``All`` destination. However the helper is much nicer and makes defining prerequisite steps a little more cleaner.\n\nThe class ``ProviderDetails`` represents the step of getting to a specific providers page, its **Details** page. This class is the same as the ``AddANewProvider`` class in that it first requires the All button to be pressed. Notice in the ``step()`` method, that there is a reference to ``self.obj``. This object is the object that is passed to navigation step as can be seen below. In the example below this object is called ``prov``.\n\n.. code-block:: python\n\n  # Non helper method\n  def prerequisite(self):\n      navigator.navigate(self.obj, 'All')\n\n  # Using helper method\n  prerequisite = NavigateToSibling('All')\n\nTo use the code above, one would instantiate a Provider object and then use the navigate method like so:\n\n.. code-block:: python\n\n\n  prov = Provider('name')\n  navigator.navigate(prov, 'Details')\n\nNavigation Helpers\n------------------\n\nnavmazing has a few helpers to make prerequisites easier to define\n\n* ``NavigateToSibling`` - Navigates to a destination that is registered to the same object as the current request.\n* ``NavigateToAttribute`` - Navigates to a destination that is registered to an attribute of the same object as the current request. This is useful if there is some kind of hierarchy to your objects and you wish to navigate to a step that is registered against an attribute rather than the object itself\n* ``NavigateToObject`` - Navigates to a destination that is registered to the supplied object, it could be argued that NavigateToAttribute could be implemented with a NavigateToObject call, by simply offering the attribute object as the object. It feels more dynamic and cleaner to use NavigateToAttribute in these cases, there the attribute is a string that is looked up, rather than an object which is static.\n\nFlowchart\n---------\n\nThe diagram below shows the flowchart of the process of resolving a navigation using the stock navmazing library. As the methods are overridable, the flow can be altered, but should suffice for most usages.\n\n.. image:: https://github.com/psav/navmazing/raw/master/flowchart.png\n\nAdvanced Usage\n--------------\n\nnavmazing also allows parameters to be passed at the navigate call. This means you can allow for some level of dynamic nature or choice in your navigation destinations. Let's say for example you have a step that usually works one way, but there are certain times when you need to override that behaviour and make it work a different way.\n\n.. code-block:: python\n\n  @navigator.register(Provider, 'Details')\n  class ProviderDetails(NavigateStep)\n      prerequisite = NavigateToSibling('All')\n\n      def step(self, active=True):\n          if choice:\n              click(self.obj.name)\n          else:\n              click(self.obj.name + \" - inactive\")\n\n  # Call by default\n  navigate(obj, 'Details')\n\n  # Call, passing in a parameter for choice\n  navigate(obj, 'Details', active=False)\n\nIn the example above, passing the ``active`` parameter changes the behaviour of the step.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "A simple navigation framework",
    "version": "1.2.2",
    "project_urls": {
        "Project": "https://github.com/RedhatQE/navmazing/"
    },
    "split_keywords": [
        "selenium",
        "navigation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1b0ab0888df24d25f6b2da3c64180ed93f3367eb18157da6fff666039448e2ee",
                "md5": "b17445d394113e479b95201ab9dc40bf",
                "sha256": "f93f7b9afa1c6cc8d77b47ac0b9a3ebc468288886d478f4a6f0f252980cdfb26"
            },
            "downloads": -1,
            "filename": "navmazing-1.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b17445d394113e479b95201ab9dc40bf",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 9384,
            "upload_time": "2023-12-04T19:12:04",
            "upload_time_iso_8601": "2023-12-04T19:12:04.282986Z",
            "url": "https://files.pythonhosted.org/packages/1b/0a/b0888df24d25f6b2da3c64180ed93f3367eb18157da6fff666039448e2ee/navmazing-1.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "034b1ff69daaa04494f199e617dcbe8544842741e91840bbd9575b8e60151322",
                "md5": "b7631ca486267e35986e4917c8fbd8e7",
                "sha256": "e691279371f0778c0c2f5cc9600ecca190b50596e3eeb0711f1acc81d8820444"
            },
            "downloads": -1,
            "filename": "navmazing-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "b7631ca486267e35986e4917c8fbd8e7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 85614,
            "upload_time": "2023-12-04T19:12:05",
            "upload_time_iso_8601": "2023-12-04T19:12:05.409047Z",
            "url": "https://files.pythonhosted.org/packages/03/4b/1ff69daaa04494f199e617dcbe8544842741e91840bbd9575b8e60151322/navmazing-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-04 19:12:05",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "RedhatQE",
    "github_project": "navmazing",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "navmazing"
}
        
Elapsed time: 0.15287s