manen


Namemanen JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/kodaho/manen/
SummaryA package around Selenium with an implementation of the page object model, an enhanced WebDriver and a CLI.
upload_time2022-02-19 12:10:33
maintainer
docs_urlNone
authorkodaho
requires_python>=3.6
licenseGPLv3
keywords automation dom page object model scraping selenium test
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
  <h1 align="center"> 🌔  manen</h1>
</p>

----

<p align="center">
  <img src="https://img.shields.io/badge/python-%3E=3.6-informational?style=for-the-badge&logo=python">
  <img alt="PyPI" src="https://img.shields.io/pypi/v/manen?logo=pypi&style=for-the-badge">
  <img src="https://img.shields.io/badge/status-in%20development-yellow?style=for-the-badge">
</p>

<p align="center">
  <i><b>A package around <a href="https://pypi.org/project/selenium/"><code>selenium</code></a> to easily construct Python objects which reflect the DOM of any webpages.</b></i>
  <i>Delivered with other features like an enhanced WebDriver and a resource manager.</i>
</p>

----

<p align="center">
  <a href="https://pypi.org/project/manen">PyPI package</a>
  ・
  <a href="https://kodaho.github.io/manen/">Documentation</a>
  ・
  <a href="https://github.com/kodaho/manen/issues">Issue tracking</a>
</p>

`manen` is a package built to extend Selenium user experience.
Among the core features, you can find:

- an implementation of the [page object model](https://www.selenium.dev/documentation/en/guidelines_and_recommendations/page_object_models/)
- a class which completes `selenium.webdriver.remote.webdriver.WebDriver`
- some helpers to manage resources usually required by Selenium
- a function to easily find and isolate DOM elements inside a page

This package will allow you to write more concise, flexible and powerful code compared to
what you could do by using only Selenium.

## 📥  Installation

The package can be installed using the official package manager `pip`.

```bash
pip install manen
```

It will install the package as well as the associated CLI.


## ✨ Features

- `manen.finder.find` allows to easily get element(s) in a HTML page. This function support
  several very different use cases, to help reduce your code complexity when fecthing for
  elements.
- `manen.resource` is a module to easily interact with all the assets needed by Selenium.
  It allows for example to download all the drivers required to interact with web browsers.
- `manen.browser` defined `Browser` objects, an enhanced Selenium's `WebDriver`.
- `manen.page_object_model` is the implementation of page object model described in Selenium
  documentation. Thanks to that, you can wrap a HTML page inside Python class and so provides
  readability and stability to your code.
- a CLI is shipped with the initial release in order to perform operations such as downloading
  driver executables.


## 🚀 Getting started

`manen` offers several features described in the [User Guide](https://kodaho.github.io/manen/user_guide.html)
of the documentation. We will give here a minimal example of what can be done with it; the goal will be to use
Selenium to explore the PyPI page of `manen` and extract some information from it.

The first step is to create an instance of a Selenium `WebDriver` or Manen `WebBrowser` that will be
used to browse the Internet.

```python
In [1]: from manen.browser import ChromeBrowser

In [2]: browser = ChromeBrowser.initialize(proxy=None, headless=True)

In [3]: browser.get("https://pypi.org")
```

![PyPI home page](./docs/assets/screenshot_pypi_home.png)

We are now on the home page of PyPI. What we are going to do now is interact with the webpage
using a manen `Page`. It will essentially use the package
[`manen.page_object_model`](https://kodaho.github.io/manen/manen/manen.page_object_model.html), that
stores all the classes used to do the interface with each web element.

```python
In [4]: import manen.page_object_model as pom
   ...:
   ...:
   ...: class HomePage(pom.Page):
   ...:     query = pom.InputElement("input[id='search']")
   ...:
   ...:
   ...: class SearchResultPage(pom.Page):
   ...:     class ResultRegions(pom.Regions):
   ...:         name = pom.TextElement("h3 span.package-snippet__name")
   ...:         version = pom.TextElement("h3 span.package-snippet__version")
   ...:         link = pom.LinkElement("a.package-snippet")
   ...:         description = pom.TextElement("p.package-snippet__description")
   ...:
   ...:     n_results = pom.IntegerElement("//*[@id='content']//form/div[1]/div[1]/p/strong")
   ...:     results = ResultRegions("ul[aria-label='Search results'] li")
```

The `Page` class is used to modelize a whole WebDriver page; all elements defined inside the class
should modelize a given element on the page, identified with the selectors (XPath, CSS or else).
For example, the class `TextElement` will extract the text from a HTML element, `LinkElement` will
extract the `href` attribute from an `a` tag. A lot of different classes exist, all of them in charge
of a special extraction; they are defined and documented in the module
[`manen.page_object_model`](https://kodaho.github.io/manen/manen/manen.page_object_model.html).

The class `Region` is used to modelize a sub-part of a webpage. Each region can have its own inner
elements. You can have as many imbricated levels as wanted.

For example, the class `HomePage` defines an `InputElement` that do the link with the search bar.
To fill a value in this search bar, you can simply assign a value to the attribute `query` of
the instance of an `HomePage`, initialized with `browser` as argument.

```python
In [5]: page = HomePage(browser)

In [6]: page.query = "manen"

In [7]: from manen.page_object_model import Action

In [8]: page.query = Action("submit")
```

Submitting the form will refer to a page with the results of our query. Let's use the class
`SearchResultPage` to retrieve the results.

![PyPI home page](./docs/assets/screenshot_pypi_search_results.png)

```python
In [9]: page = SearchResultPage(browser)

In [10]: page.n_results
Out[10]: 1

In [11]: page.results
Out[11]: [<__main__.SearchResultPage.ResultRegions at 0x1058e97c0>]

In [12]: print(
    ...:     f"Name: {page.results[0].name}",
    ...:     f"Description: {page.results[0].description[:80]}...",
    ...:     f"Version: {page.results[0].version}",
    ...:     f"Link: {page.results[0].link}",
    ...:     sep="\n",
    ...: )
Name: manen
Description: A package around `selenium` offering, among other features, an implementation of...
Version: 0.1.0
Link: https://pypi.org/project/manen/
```

Last step is to close the browser to avoid any remaining running application once we close Python.
```python
In [13]: browser.quit()
```


## 🦾 Going further

The best way to have full knowledge of the package is to read
[the documentation of the project](https://kodaho.github.io/manen/)!

If you want to have the exhaustive list of improvements of the package, check the
[Changelog](https://kodaho.github.io/manen/changelog.html) page.

Looking to contribute to fix or add new features? Just read
[this page](https://kodaho.github.io/manen/contributing.html),
fork the official repository and start doing the modifications you want.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kodaho/manen/",
    "name": "manen",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "automation,DOM,page object model,scraping,selenium,test",
    "author": "kodaho",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/c9/ed/1a12e90b497b184a5a279a1e5ce302cd366d9e843ea41e3f86aa81a2c440/manen-0.2.0.tar.gz",
    "platform": "any",
    "description": "<p align=\"center\">\n  <h1 align=\"center\"> \ud83c\udf14  manen</h1>\n</p>\n\n----\n\n<p align=\"center\">\n  <img src=\"https://img.shields.io/badge/python-%3E=3.6-informational?style=for-the-badge&logo=python\">\n  <img alt=\"PyPI\" src=\"https://img.shields.io/pypi/v/manen?logo=pypi&style=for-the-badge\">\n  <img src=\"https://img.shields.io/badge/status-in%20development-yellow?style=for-the-badge\">\n</p>\n\n<p align=\"center\">\n  <i><b>A package around <a href=\"https://pypi.org/project/selenium/\"><code>selenium</code></a> to easily construct Python objects which reflect the DOM of any webpages.</b></i>\n  <i>Delivered with other features like an enhanced WebDriver and a resource manager.</i>\n</p>\n\n----\n\n<p align=\"center\">\n  <a href=\"https://pypi.org/project/manen\">PyPI package</a>\n  \u30fb\n  <a href=\"https://kodaho.github.io/manen/\">Documentation</a>\n  \u30fb\n  <a href=\"https://github.com/kodaho/manen/issues\">Issue tracking</a>\n</p>\n\n`manen` is a package built to extend Selenium user experience.\nAmong the core features, you can find:\n\n- an implementation of the [page object model](https://www.selenium.dev/documentation/en/guidelines_and_recommendations/page_object_models/)\n- a class which completes `selenium.webdriver.remote.webdriver.WebDriver`\n- some helpers to manage resources usually required by Selenium\n- a function to easily find and isolate DOM elements inside a page\n\nThis package will allow you to write more concise, flexible and powerful code compared to\nwhat you could do by using only Selenium.\n\n## \ud83d\udce5  Installation\n\nThe package can be installed using the official package manager `pip`.\n\n```bash\npip install manen\n```\n\nIt will install the package as well as the associated CLI.\n\n\n## \u2728 Features\n\n- `manen.finder.find` allows to easily get element(s) in a HTML page. This function support\n  several very different use cases, to help reduce your code complexity when fecthing for\n  elements.\n- `manen.resource` is a module to easily interact with all the assets needed by Selenium.\n  It allows for example to download all the drivers required to interact with web browsers.\n- `manen.browser` defined `Browser` objects, an enhanced Selenium's `WebDriver`.\n- `manen.page_object_model` is the implementation of page object model described in Selenium\n  documentation. Thanks to that, you can wrap a HTML page inside Python class and so provides\n  readability and stability to your code.\n- a CLI is shipped with the initial release in order to perform operations such as downloading\n  driver executables.\n\n\n## \ud83d\ude80 Getting started\n\n`manen` offers several features described in the [User Guide](https://kodaho.github.io/manen/user_guide.html)\nof the documentation. We will give here a minimal example of what can be done with it; the goal will be to use\nSelenium to explore the PyPI page of `manen` and extract some information from it.\n\nThe first step is to create an instance of a Selenium `WebDriver` or Manen `WebBrowser` that will be\nused to browse the Internet.\n\n```python\nIn [1]: from manen.browser import ChromeBrowser\n\nIn [2]: browser = ChromeBrowser.initialize(proxy=None, headless=True)\n\nIn [3]: browser.get(\"https://pypi.org\")\n```\n\n![PyPI home page](./docs/assets/screenshot_pypi_home.png)\n\nWe are now on the home page of PyPI. What we are going to do now is interact with the webpage\nusing a manen `Page`. It will essentially use the package\n[`manen.page_object_model`](https://kodaho.github.io/manen/manen/manen.page_object_model.html), that\nstores all the classes used to do the interface with each web element.\n\n```python\nIn [4]: import manen.page_object_model as pom\n   ...:\n   ...:\n   ...: class HomePage(pom.Page):\n   ...:     query = pom.InputElement(\"input[id='search']\")\n   ...:\n   ...:\n   ...: class SearchResultPage(pom.Page):\n   ...:     class ResultRegions(pom.Regions):\n   ...:         name = pom.TextElement(\"h3 span.package-snippet__name\")\n   ...:         version = pom.TextElement(\"h3 span.package-snippet__version\")\n   ...:         link = pom.LinkElement(\"a.package-snippet\")\n   ...:         description = pom.TextElement(\"p.package-snippet__description\")\n   ...:\n   ...:     n_results = pom.IntegerElement(\"//*[@id='content']//form/div[1]/div[1]/p/strong\")\n   ...:     results = ResultRegions(\"ul[aria-label='Search results'] li\")\n```\n\nThe `Page` class is used to modelize a whole WebDriver page; all elements defined inside the class\nshould modelize a given element on the page, identified with the selectors (XPath, CSS or else).\nFor example, the class `TextElement` will extract the text from a HTML element, `LinkElement` will\nextract the `href` attribute from an `a` tag. A lot of different classes exist, all of them in charge\nof a special extraction; they are defined and documented in the module\n[`manen.page_object_model`](https://kodaho.github.io/manen/manen/manen.page_object_model.html).\n\nThe class `Region` is used to modelize a sub-part of a webpage. Each region can have its own inner\nelements. You can have as many imbricated levels as wanted.\n\nFor example, the class `HomePage` defines an `InputElement` that do the link with the search bar.\nTo fill a value in this search bar, you can simply assign a value to the attribute `query` of\nthe instance of an `HomePage`, initialized with `browser` as argument.\n\n```python\nIn [5]: page = HomePage(browser)\n\nIn [6]: page.query = \"manen\"\n\nIn [7]: from manen.page_object_model import Action\n\nIn [8]: page.query = Action(\"submit\")\n```\n\nSubmitting the form will refer to a page with the results of our query. Let's use the class\n`SearchResultPage` to retrieve the results.\n\n![PyPI home page](./docs/assets/screenshot_pypi_search_results.png)\n\n```python\nIn [9]: page = SearchResultPage(browser)\n\nIn [10]: page.n_results\nOut[10]: 1\n\nIn [11]: page.results\nOut[11]: [<__main__.SearchResultPage.ResultRegions at 0x1058e97c0>]\n\nIn [12]: print(\n    ...:     f\"Name: {page.results[0].name}\",\n    ...:     f\"Description: {page.results[0].description[:80]}...\",\n    ...:     f\"Version: {page.results[0].version}\",\n    ...:     f\"Link: {page.results[0].link}\",\n    ...:     sep=\"\\n\",\n    ...: )\nName: manen\nDescription: A package around `selenium` offering, among other features, an implementation of...\nVersion: 0.1.0\nLink: https://pypi.org/project/manen/\n```\n\nLast step is to close the browser to avoid any remaining running application once we close Python.\n```python\nIn [13]: browser.quit()\n```\n\n\n## \ud83e\uddbe Going further\n\nThe best way to have full knowledge of the package is to read\n[the documentation of the project](https://kodaho.github.io/manen/)!\n\nIf you want to have the exhaustive list of improvements of the package, check the\n[Changelog](https://kodaho.github.io/manen/changelog.html) page.\n\nLooking to contribute to fix or add new features? Just read\n[this page](https://kodaho.github.io/manen/contributing.html),\nfork the official repository and start doing the modifications you want.\n\n\n",
    "bugtrack_url": null,
    "license": "GPLv3",
    "summary": "A package around Selenium with an implementation of the page object model, an enhanced WebDriver and a CLI.",
    "version": "0.2.0",
    "project_urls": {
        "Changes": "https://kodaho.github.io/manen/changelog.html",
        "Documentation": "https://kodaho.github.io/manen/",
        "Homepage": "https://github.com/kodaho/manen/",
        "Issue Tracker": "https://github.com/kodaho/manen/issues/",
        "Source Code": "https://github.com/kodaho/manen/"
    },
    "split_keywords": [
        "automation",
        "dom",
        "page object model",
        "scraping",
        "selenium",
        "test"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e3169d9980435e54364136f6d2e1790e69fe089d06b48e93f3716c9ba751a5bc",
                "md5": "abe848d58aea56fcc665407a2c84a9d0",
                "sha256": "a56a1fc66d723c7bc723c4d033e2fbcc0012bc295979fbbca9a39e185b39e6b7"
            },
            "downloads": -1,
            "filename": "manen-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "abe848d58aea56fcc665407a2c84a9d0",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 40847,
            "upload_time": "2022-02-19T12:10:31",
            "upload_time_iso_8601": "2022-02-19T12:10:31.625327Z",
            "url": "https://files.pythonhosted.org/packages/e3/16/9d9980435e54364136f6d2e1790e69fe089d06b48e93f3716c9ba751a5bc/manen-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c9ed1a12e90b497b184a5a279a1e5ce302cd366d9e843ea41e3f86aa81a2c440",
                "md5": "203bf43347e3b96a9e24d103e67e395d",
                "sha256": "2a34429c4db5d506d05569ba117e87a11f09c3e5dc10667b742b96cc56815af4"
            },
            "downloads": -1,
            "filename": "manen-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "203bf43347e3b96a9e24d103e67e395d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 39907,
            "upload_time": "2022-02-19T12:10:33",
            "upload_time_iso_8601": "2022-02-19T12:10:33.312691Z",
            "url": "https://files.pythonhosted.org/packages/c9/ed/1a12e90b497b184a5a279a1e5ce302cd366d9e843ea41e3f86aa81a2c440/manen-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-02-19 12:10:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kodaho",
    "github_project": "manen",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "manen"
}
        
Elapsed time: 0.31874s