cucu


Namecucu JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryEasy BDD web testing
upload_time2024-10-03 00:13:16
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseThe Clear BSD License
keywords behave cucumber selenium
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ![Cucu Logo](https://raw.githubusercontent.com/dominodatalab/cucu/refs/heads/main/logo.png) **CUCU** - Easy BDD web testing <!-- omit from toc -->

End-to-end testing framework that uses [gherkin](https://cucumber.io/docs/gherkin/)
to drive various underlying tools/frameworks to create real world testing scenarios.

[![CircleCI](https://dl.circleci.com/status-badge/img/gh/dominodatalab/cucu/tree/main.svg?style=svg&circle-token=CCIPRJ_FnyZPtQ9odT5vmGW3CmZNU_bf0cfd776a09729ca4225a2860d9b59c4dae88af)](https://dl.circleci.com/status-badge/redirect/gh/dominodatalab/cucu/tree/main)

## Why cucu? <!-- omit from toc -->
1. Cucu avoids unnecessary abstractions (i.e. no Page Objects!) while keeping scenarios readable.
    ```gherkin
    Feature: My First Cucu Test
      We want to be sure the user get search results using the landing page

      Scenario: User can get search results
        Given I open a browser at the url "https://www.google.com/search"
         When I wait to write "google" into the input "Search"
          And I click the button "Google Search"
         Then I wait to see the text "results"
    ```
2. Designed to be run **locally** and in **CI**
3. Runs a selenium container for you OR you can bring your own browser / container
4. Does fuzzy matching to approximate actions of a real user
5. Provides many steps out of the box
6. Makes it easy to create **customized** steps
7. Enables hierarchical configuration and env var and **CLI arg overrides**
8. Comes with a linter that is **customizable**

## Supporting docs <!-- omit from toc -->
1. [CHANGELOG.md](CHANGELOG.md) - for latest news
2. [CONTRIBUTING.md](CONTRIBUTING.md) - how we develop and test the library
3. [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
4. [CONTRIBUTORS.md](CONTRIBUTORS.md)
5. [LICENSE](LICENSE)

# Table of Contents <!-- omit from toc -->

- [Installation](#installation)
  - [Requirements](#requirements)
  - [Install Walkthrough](#install-walkthrough)
- [Usage](#usage)
  - [Cucu Run](#cucu-run)
  - [Run specific browser version with docker](#run-specific-browser-version-with-docker)
- [Extending Cucu](#extending-cucu)
  - [Fuzzy matching](#fuzzy-matching)
  - [Custom steps](#custom-steps)
  - [Before / After hooks](#before--after-hooks)
  - [Custom lint rules](#custom-lint-rules)
- [More Ways To Install Cucu](#more-ways-to-install-cucu)
  - [Install From Build](#install-from-build)

# Installation
## Requirements
Cucu requires
1. python 3.9+
2. docker (to do UI testing)

## Install Walkthrough
_Get your repo setup using cucu as a test framework_

1. install and start Docker if you haven't already
2. install [cucu](https://pypi.org/project/cucu/)
   ```
   pip install cucu
   ```
3. create the folder structure and files with content:
    _Cucu uses the [behave framework](https://github.com/behave/behave) which expects the `features/steps` directories_
   - features/
      - steps/
      - `__init__.py` # enables cucu and custom steps
        ```python
        # import all of the steps from cucu
        from cucu.steps import *  # noqa: F403, F401

        # import individual sub-modules here (i.e. module names of your custom step py files)
        # Example: For file features/steps/ui/login.py
        # import steps.ui.login_steps
        ```
   - environment.py - enables before/after hooks
     ```python
     # flake8: noqa
     from cucu.environment import *

     # Define custom before/after hooks here
     ```
4. list available cucu steps
   ```bash
   cucu steps
   ```
   - if you have `brew install fzf` then you can fuzzy find steps
     ```bash
     cucu steps | fzf
     # start typing for search
     ```
5. **create your first cucu test**
   - features/my_first_test.feature
     ```gherkin
     Feature: My First Cucu Test
       We want to be sure the user get search results using the landing page

       Scenario: User can get search results
         Given I open a browser at the url "https://www.google.com/search"
          When I wait to write "google" into the input "Search"
           And I click the button "Google Search"
          Then I wait to see the text "results"
     ```
6. **run it**
   ```bash
   cucu run features/my_first_test.feature
   ```

# Usage
## Cucu Run
The command `cucu run` is used to run a given test or set of tests and in its
simplest form you can use it like so:
```bash
cucu run features/my_first_test.feature
```

That would simply run the "google search for the word google" and once it's
finished executing you can use the `cucu report` command to generate an easy
to navigate and read HTML test report which includes the steps and screenshots
from that previous test run.

*NOTE:*
By default we'll simply use the `Google Chrome` you have installed and there's
a python package that'll handle downloading chromedriver that matches your
specific local Google Chrome version.

## Run specific browser version with docker

[docker hub](https://hub.docker.com/) has easy to use docker containers for
running specific versions of chrome, edge and firefox browsers for testing that
you can spin up manually in standalone mode like so:

```bash
docker run -d -p 4444:4444 selenium/standalone-chrome:latest
```

If you are using ARM64 CPU architecture (Mac M1 or M2), you must use seleniarm
container.

```bash
docker run -d -p 4444:4444 seleniarm/standalone-chromium:latest
```

And can choose a specific version replacing the `latest` with any tag from
[here](https://hub.docker.com/r/selenium/standalone-chrome/tags). You can find
browser tags for `standalone-edge` and `standalone-firefox` the same way. Once
you run the command you will see with `docker  ps -a` that the container
is running and listening on port `4444`:

Specific tags for seleniarm:
[here](https://hub.docker.com/r/seleniarm/standalone-chromium/tags)

```bash
> docker ps -a
CONTAINER ID ... PORTS                                                NAMES
7c719f4bee29 ... 0.0.0.0:4444->4444/tcp, :::4444->4444/tcp, 5900/tcp  wizardly_haslett
```

*NOTE:* For seleniarm containers, the available browsers are chromium and firefox.
The reason for this is because Google and Microsoft have not released binaries
for their respective browsers (Chrome and Edge).

Now when running `cucu run some.feature` you can provide
`--selenium-remote-url http://localhost:4444` and this way you'll run a very
specific version of chrome on any setup you run this on.

You can also create a docker hub setup with all 3 browser nodes connected using
the utilty script at `./bin/start_selenium_hub.sh` and you can point your tests
at `http://localhost:4444` and then specify the `--browser` to be `chrome`,
`firefox` or `edge` and use that specific browser for testing.

The docker hub setup for seleniarm: `./bin/start_seleniarm_hub.sh`
*NOTE:* `edge` cannot be selected as a specific browser for testing

To ease using various custom settings you can also set most of the command line
options in a local `cucurc.yml` or in a more global place at `~/.cucurc.yml`
the same settings. For the remote url above you'd simply have the following
in your `cucurc.yml`:

```bash
CUCU_SELENIUM_REMOTE_URL: http://localhost:4444
```

Then you can simply run `cucu run path/to/some.feature` and `cucu` would load
the local `cucurc.yml` or `~/.cucurc.yml` settings and use those.

# Extending Cucu

## Fuzzy matching

`cucu` uses selenium to interact with the browser but on top of that we've
developed a fuzzy matching set of rules that allow the framework to find
elements on the page by having a label and a type of element we're searching for.

The principal is simple you want to `click the button "Foo"` so we know you want
to find a button which can be one of a few different kind of HTML elements:

  * `<a>`
  * `<button>`
  * `<input type="button">`
  * `<* role="button">`
  * etc

We also know that it has the name you provided labeling it and that can be
done using any of the following rules:

  * `<thing>name</thing>`
  * `<*>name</*><thing></thing>`
  * `<thing attribute="name"></thing>`
  * `<*>name</*>...<thing>...`

Where `thing` is any of the previously identified element types. With the above
rules we created a simple method method that uses the those rules to find a set
of elements labeled with the name you provide and type of elements you're
looking for. We currently use [swizzle](https://github.com/jquery/sizzle) as
the underlying element query language as its highly portable and has a bit
useful features than basic CSS gives us.

## Custom steps
It's easy to create custom steps, for example:
1. create a new python file in your repo `features/steps/ui/weird_button_steps.py`
    ```python
    from cucu import fuzzy, retry, step

    # make this step available for scenarios and listed in `cucu steps`
    @step('I open the wierd menu item "{menu_item}"')
    def open_jupyter_menu(ctx, menu_item):
        # using fuzzy.find
        dropdown_item = fuzzy.find(ctx.browser, menu_item, ["li a"])
        dropdown_item.click()

    # example using retry
    def click_that_weird_button(ctx):
        # using selenium's css_find_elements
        ctx.browser.css_find_elements("button[custom_thing='painful-id']")[0].click()

    @step("I wait to click this button that isn't aria compliant on my page")
    def wait_to_click_that_weird_button(ctx):
        # makes this retry with the default wait timeout
        retry(click_that_weird_button)(ctx)  # remember to call the returned function `(ctx)` at the end
    ```
2. then update the magic `features/steps/__init__.py` file (this one file only!)

   _Yeah I know that this is kind of odd, but work with me here😅_
    ```python
    # import all of the steps from cucu
    from cucu.steps import *  # noqa: F403, F401

    # import individual sub-modules here (i.e. module names of your custom step py files)
    # Example: For file features/steps/ui/login.py
    # import steps.ui.login_steps
    import steps.ui.weird_button_steps
    ```
3. profit!

## Before / After hooks

There are several hooks you can access, here's a few:
```python
register_before_retry_hook,
register_before_scenario_hook,
register_custom_junit_failure_handler,
register_custom_tags_in_report_handling,
register_custom_scenario_subheader_in_report_handling,
register_custom_variable_handling,
register_page_check_hook,
```

And here's an example:
1. add your function def to `features/environment.py`
   ```python
    import logging

    from cucu import (
        fuzzy,
        logger,
        register_page_check_hook,
        retry,
    )
    from cucu.config import CONFIG
    from cucu.environment import *

    def print_elements(elements):
        """
        given a list of selenium web elements we print their outerHTML
        representation to the logs
        """
        for element in elements:
            logger.debug(f"found element: {element.get_attribute('outerHTML')}")

    def wait_for_my_loading_indicators(browser):
       # aria-label="loading"
       def should_not_see_aria_label_equals_loading():
          # ignore the checks on the my-page page as there are these silly
          # spinners that have aria-label=loading and probably shouldn't
          if "my-page" not in browser.get_current_url():
             elements = browser.css_find_elements("[aria-label='loading'")
             if elements:
                   print_elements(elements)
                   raise RuntimeError("aria-label='loading', see above for details")

       retry(should_not_see_aria_label_equals_loading)()

       # my-attr contains "loading"
       def should_not_see_data_test_contains_loading():
          elements = browser.css_find_elements("[my-attr*='loading'")
          if elements:
             print_elements(elements)
             raise RuntimeError("my-attr*='loading', see above for details")

       retry(should_not_see_data_test_contains_loading)()

       # class contains "my-spinner"
       def should_not_see_class_contains_my_spinner():
          elements = browser.css_find_elements("[class*='my-spinner'")
          if elements:
             print_elements(elements)
             raise RuntimeError("class*='my-spinner', see above for details")

       retry(should_not_see_class_contains_my_spinner)()


    register_page_check_hook("my loading indicators", wait_for_my_loading_indicators)
   ```
2. done!

## Custom lint rules

You can easily extend the `cucu lint` linting rules by setting the variable
`CUCU_LINT_RULES_PATH` and pointing it to a directory in your features source
that has `.yaml` files that are structured like so:

```yaml
[unique_rule_identifier]:
  message: [the message to provide the end user explaining the violation]
  type: [warning|error] # I or W  will be printed when reporting the violation
  current_line:
    match: [regex]
  previous_line:
    match: [regex]
  next_line:
    match: [regex]
  fix:
    match: [regex]
    replace: [regex]
    -- or --
    delete: true
```

The `current_line`, `previous_line` and `next_line` sections are used to match
on a specific set of lines so that you can then "fix" the current line a way
specified by the `fix` block. When there is no `fix` block provided then
`cucu lint` will notify the end user it can not fix the violation.

In the `fix` section one can choose to do `match` and `replace` or to simply
`delete` the violating line.

# More Ways To Install Cucu

## Install From Build

Within the cucu directory you can run `uv build` and that will produce some
output like so:

```bash
Building source distribution...
Building wheel from source distribution...
Successfully built dist/cucu-0.207.0.tar.gz and dist/cucu-0.207.0-py3-none-any.whl
```

At this point you can install the file `dist/cucu-0.1.0.tar.gz` using
`pip install .../cucu/dist/cucu-*.tar.gz` anywhere you'd like and have the `cucu` tool ready to
run.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cucu",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "Domino Data Lab <open-source@dominodatalab.com>, Cedric Young <4129217+ccedricyoung@users.noreply.github.com>, Kevin Garton <71028750+ddl-kgarton@users.noreply.github.com>, Brian Colby <92048365+ddl-bcolby@users.noreply.github.com>",
    "keywords": "behave, cucumber, selenium",
    "author": null,
    "author_email": "Domino Data Lab <open-source@dominodatalab.com>, Rodney Gomes <107359+rlgomes@users.noreply.github.com>, Cedric Young <4129217+ccedricyoung@users.noreply.github.com>, Xin Dong <104880864+ddl-xin@users.noreply.github.com>, Kavya <91882851+ddl-kavya@users.noreply.github.com>, Kevin Garton <71028750+ddl-kgarton@users.noreply.github.com>, Joy Liao <107583686+ddl-joy-liao@users.noreply.github.com>",
    "download_url": "https://files.pythonhosted.org/packages/05/a7/2b9b75cfe31e30d45bd133122526db6e98b2c45b4d82d4e9d3fe76aab1aa/cucu-1.0.2.tar.gz",
    "platform": null,
    "description": "# ![Cucu Logo](https://raw.githubusercontent.com/dominodatalab/cucu/refs/heads/main/logo.png) **CUCU** - Easy BDD web testing <!-- omit from toc -->\n\nEnd-to-end testing framework that uses [gherkin](https://cucumber.io/docs/gherkin/)\nto drive various underlying tools/frameworks to create real world testing scenarios.\n\n[![CircleCI](https://dl.circleci.com/status-badge/img/gh/dominodatalab/cucu/tree/main.svg?style=svg&circle-token=CCIPRJ_FnyZPtQ9odT5vmGW3CmZNU_bf0cfd776a09729ca4225a2860d9b59c4dae88af)](https://dl.circleci.com/status-badge/redirect/gh/dominodatalab/cucu/tree/main)\n\n## Why cucu? <!-- omit from toc -->\n1. Cucu avoids unnecessary abstractions (i.e. no Page Objects!) while keeping scenarios readable.\n    ```gherkin\n    Feature: My First Cucu Test\n      We want to be sure the user get search results using the landing page\n\n      Scenario: User can get search results\n        Given I open a browser at the url \"https://www.google.com/search\"\n         When I wait to write \"google\" into the input \"Search\"\n          And I click the button \"Google Search\"\n         Then I wait to see the text \"results\"\n    ```\n2. Designed to be run **locally** and in **CI**\n3. Runs a selenium container for you OR you can bring your own browser / container\n4. Does fuzzy matching to approximate actions of a real user\n5. Provides many steps out of the box\n6. Makes it easy to create **customized** steps\n7. Enables hierarchical configuration and env var and **CLI arg overrides**\n8. Comes with a linter that is **customizable**\n\n## Supporting docs <!-- omit from toc -->\n1. [CHANGELOG.md](CHANGELOG.md) - for latest news\n2. [CONTRIBUTING.md](CONTRIBUTING.md) - how we develop and test the library\n3. [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)\n4. [CONTRIBUTORS.md](CONTRIBUTORS.md)\n5. [LICENSE](LICENSE)\n\n# Table of Contents <!-- omit from toc -->\n\n- [Installation](#installation)\n  - [Requirements](#requirements)\n  - [Install Walkthrough](#install-walkthrough)\n- [Usage](#usage)\n  - [Cucu Run](#cucu-run)\n  - [Run specific browser version with docker](#run-specific-browser-version-with-docker)\n- [Extending Cucu](#extending-cucu)\n  - [Fuzzy matching](#fuzzy-matching)\n  - [Custom steps](#custom-steps)\n  - [Before / After hooks](#before--after-hooks)\n  - [Custom lint rules](#custom-lint-rules)\n- [More Ways To Install Cucu](#more-ways-to-install-cucu)\n  - [Install From Build](#install-from-build)\n\n# Installation\n## Requirements\nCucu requires\n1. python 3.9+\n2. docker (to do UI testing)\n\n## Install Walkthrough\n_Get your repo setup using cucu as a test framework_\n\n1. install and start Docker if you haven't already\n2. install [cucu](https://pypi.org/project/cucu/)\n   ```\n   pip install cucu\n   ```\n3. create the folder structure and files with content:\n    _Cucu uses the [behave framework](https://github.com/behave/behave) which expects the `features/steps` directories_\n   - features/\n      - steps/\n      - `__init__.py` # enables cucu and custom steps\n        ```python\n        # import all of the steps from cucu\n        from cucu.steps import *  # noqa: F403, F401\n\n        # import individual sub-modules here (i.e. module names of your custom step py files)\n        # Example: For file features/steps/ui/login.py\n        # import steps.ui.login_steps\n        ```\n   - environment.py - enables before/after hooks\n     ```python\n     # flake8: noqa\n     from cucu.environment import *\n\n     # Define custom before/after hooks here\n     ```\n4. list available cucu steps\n   ```bash\n   cucu steps\n   ```\n   - if you have `brew install fzf` then you can fuzzy find steps\n     ```bash\n     cucu steps | fzf\n     # start typing for search\n     ```\n5. **create your first cucu test**\n   - features/my_first_test.feature\n     ```gherkin\n     Feature: My First Cucu Test\n       We want to be sure the user get search results using the landing page\n\n       Scenario: User can get search results\n         Given I open a browser at the url \"https://www.google.com/search\"\n          When I wait to write \"google\" into the input \"Search\"\n           And I click the button \"Google Search\"\n          Then I wait to see the text \"results\"\n     ```\n6. **run it**\n   ```bash\n   cucu run features/my_first_test.feature\n   ```\n\n# Usage\n## Cucu Run\nThe command `cucu run` is used to run a given test or set of tests and in its\nsimplest form you can use it like so:\n```bash\ncucu run features/my_first_test.feature\n```\n\nThat would simply run the \"google search for the word google\" and once it's\nfinished executing you can use the `cucu report` command to generate an easy\nto navigate and read HTML test report which includes the steps and screenshots\nfrom that previous test run.\n\n*NOTE:*\nBy default we'll simply use the `Google Chrome` you have installed and there's\na python package that'll handle downloading chromedriver that matches your\nspecific local Google Chrome version.\n\n## Run specific browser version with docker\n\n[docker hub](https://hub.docker.com/) has easy to use docker containers for\nrunning specific versions of chrome, edge and firefox browsers for testing that\nyou can spin up manually in standalone mode like so:\n\n```bash\ndocker run -d -p 4444:4444 selenium/standalone-chrome:latest\n```\n\nIf you are using ARM64 CPU architecture (Mac M1 or M2), you must use seleniarm\ncontainer.\n\n```bash\ndocker run -d -p 4444:4444 seleniarm/standalone-chromium:latest\n```\n\nAnd can choose a specific version replacing the `latest` with any tag from\n[here](https://hub.docker.com/r/selenium/standalone-chrome/tags). You can find\nbrowser tags for `standalone-edge` and `standalone-firefox` the same way. Once\nyou run the command you will see with `docker  ps -a` that the container\nis running and listening on port `4444`:\n\nSpecific tags for seleniarm:\n[here](https://hub.docker.com/r/seleniarm/standalone-chromium/tags)\n\n```bash\n> docker ps -a\nCONTAINER ID ... PORTS                                                NAMES\n7c719f4bee29 ... 0.0.0.0:4444->4444/tcp, :::4444->4444/tcp, 5900/tcp  wizardly_haslett\n```\n\n*NOTE:* For seleniarm containers, the available browsers are chromium and firefox.\nThe reason for this is because Google and Microsoft have not released binaries\nfor their respective browsers (Chrome and Edge).\n\nNow when running `cucu run some.feature` you can provide\n`--selenium-remote-url http://localhost:4444` and this way you'll run a very\nspecific version of chrome on any setup you run this on.\n\nYou can also create a docker hub setup with all 3 browser nodes connected using\nthe utilty script at `./bin/start_selenium_hub.sh` and you can point your tests\nat `http://localhost:4444` and then specify the `--browser` to be `chrome`,\n`firefox` or `edge` and use that specific browser for testing.\n\nThe docker hub setup for seleniarm: `./bin/start_seleniarm_hub.sh`\n*NOTE:* `edge` cannot be selected as a specific browser for testing\n\nTo ease using various custom settings you can also set most of the command line\noptions in a local `cucurc.yml` or in a more global place at `~/.cucurc.yml`\nthe same settings. For the remote url above you'd simply have the following\nin your `cucurc.yml`:\n\n```bash\nCUCU_SELENIUM_REMOTE_URL: http://localhost:4444\n```\n\nThen you can simply run `cucu run path/to/some.feature` and `cucu` would load\nthe local `cucurc.yml` or `~/.cucurc.yml` settings and use those.\n\n# Extending Cucu\n\n## Fuzzy matching\n\n`cucu` uses selenium to interact with the browser but on top of that we've\ndeveloped a fuzzy matching set of rules that allow the framework to find\nelements on the page by having a label and a type of element we're searching for.\n\nThe principal is simple you want to `click the button \"Foo\"` so we know you want\nto find a button which can be one of a few different kind of HTML elements:\n\n  * `<a>`\n  * `<button>`\n  * `<input type=\"button\">`\n  * `<* role=\"button\">`\n  * etc\n\nWe also know that it has the name you provided labeling it and that can be\ndone using any of the following rules:\n\n  * `<thing>name</thing>`\n  * `<*>name</*><thing></thing>`\n  * `<thing attribute=\"name\"></thing>`\n  * `<*>name</*>...<thing>...`\n\nWhere `thing` is any of the previously identified element types. With the above\nrules we created a simple method method that uses the those rules to find a set\nof elements labeled with the name you provide and type of elements you're\nlooking for. We currently use [swizzle](https://github.com/jquery/sizzle) as\nthe underlying element query language as its highly portable and has a bit\nuseful features than basic CSS gives us.\n\n## Custom steps\nIt's easy to create custom steps, for example:\n1. create a new python file in your repo `features/steps/ui/weird_button_steps.py`\n    ```python\n    from cucu import fuzzy, retry, step\n\n    # make this step available for scenarios and listed in `cucu steps`\n    @step('I open the wierd menu item \"{menu_item}\"')\n    def open_jupyter_menu(ctx, menu_item):\n        # using fuzzy.find\n        dropdown_item = fuzzy.find(ctx.browser, menu_item, [\"li a\"])\n        dropdown_item.click()\n\n    # example using retry\n    def click_that_weird_button(ctx):\n        # using selenium's css_find_elements\n        ctx.browser.css_find_elements(\"button[custom_thing='painful-id']\")[0].click()\n\n    @step(\"I wait to click this button that isn't aria compliant on my page\")\n    def wait_to_click_that_weird_button(ctx):\n        # makes this retry with the default wait timeout\n        retry(click_that_weird_button)(ctx)  # remember to call the returned function `(ctx)` at the end\n    ```\n2. then update the magic `features/steps/__init__.py` file (this one file only!)\n\n   _Yeah I know that this is kind of odd, but work with me here\ud83d\ude05_\n    ```python\n    # import all of the steps from cucu\n    from cucu.steps import *  # noqa: F403, F401\n\n    # import individual sub-modules here (i.e. module names of your custom step py files)\n    # Example: For file features/steps/ui/login.py\n    # import steps.ui.login_steps\n    import steps.ui.weird_button_steps\n    ```\n3. profit!\n\n## Before / After hooks\n\nThere are several hooks you can access, here's a few:\n```python\nregister_before_retry_hook,\nregister_before_scenario_hook,\nregister_custom_junit_failure_handler,\nregister_custom_tags_in_report_handling,\nregister_custom_scenario_subheader_in_report_handling,\nregister_custom_variable_handling,\nregister_page_check_hook,\n```\n\nAnd here's an example:\n1. add your function def to `features/environment.py`\n   ```python\n    import logging\n\n    from cucu import (\n        fuzzy,\n        logger,\n        register_page_check_hook,\n        retry,\n    )\n    from cucu.config import CONFIG\n    from cucu.environment import *\n\n    def print_elements(elements):\n        \"\"\"\n        given a list of selenium web elements we print their outerHTML\n        representation to the logs\n        \"\"\"\n        for element in elements:\n            logger.debug(f\"found element: {element.get_attribute('outerHTML')}\")\n\n    def wait_for_my_loading_indicators(browser):\n       # aria-label=\"loading\"\n       def should_not_see_aria_label_equals_loading():\n          # ignore the checks on the my-page page as there are these silly\n          # spinners that have aria-label=loading and probably shouldn't\n          if \"my-page\" not in browser.get_current_url():\n             elements = browser.css_find_elements(\"[aria-label='loading'\")\n             if elements:\n                   print_elements(elements)\n                   raise RuntimeError(\"aria-label='loading', see above for details\")\n\n       retry(should_not_see_aria_label_equals_loading)()\n\n       # my-attr contains \"loading\"\n       def should_not_see_data_test_contains_loading():\n          elements = browser.css_find_elements(\"[my-attr*='loading'\")\n          if elements:\n             print_elements(elements)\n             raise RuntimeError(\"my-attr*='loading', see above for details\")\n\n       retry(should_not_see_data_test_contains_loading)()\n\n       # class contains \"my-spinner\"\n       def should_not_see_class_contains_my_spinner():\n          elements = browser.css_find_elements(\"[class*='my-spinner'\")\n          if elements:\n             print_elements(elements)\n             raise RuntimeError(\"class*='my-spinner', see above for details\")\n\n       retry(should_not_see_class_contains_my_spinner)()\n\n\n    register_page_check_hook(\"my loading indicators\", wait_for_my_loading_indicators)\n   ```\n2. done!\n\n## Custom lint rules\n\nYou can easily extend the `cucu lint` linting rules by setting the variable\n`CUCU_LINT_RULES_PATH` and pointing it to a directory in your features source\nthat has `.yaml` files that are structured like so:\n\n```yaml\n[unique_rule_identifier]:\n  message: [the message to provide the end user explaining the violation]\n  type: [warning|error] # I or W  will be printed when reporting the violation\n  current_line:\n    match: [regex]\n  previous_line:\n    match: [regex]\n  next_line:\n    match: [regex]\n  fix:\n    match: [regex]\n    replace: [regex]\n    -- or --\n    delete: true\n```\n\nThe `current_line`, `previous_line` and `next_line` sections are used to match\non a specific set of lines so that you can then \"fix\" the current line a way\nspecified by the `fix` block. When there is no `fix` block provided then\n`cucu lint` will notify the end user it can not fix the violation.\n\nIn the `fix` section one can choose to do `match` and `replace` or to simply\n`delete` the violating line.\n\n# More Ways To Install Cucu\n\n## Install From Build\n\nWithin the cucu directory you can run `uv build` and that will produce some\noutput like so:\n\n```bash\nBuilding source distribution...\nBuilding wheel from source distribution...\nSuccessfully built dist/cucu-0.207.0.tar.gz and dist/cucu-0.207.0-py3-none-any.whl\n```\n\nAt this point you can install the file `dist/cucu-0.1.0.tar.gz` using\n`pip install .../cucu/dist/cucu-*.tar.gz` anywhere you'd like and have the `cucu` tool ready to\nrun.\n",
    "bugtrack_url": null,
    "license": "The Clear BSD License",
    "summary": "Easy BDD web testing",
    "version": "1.0.2",
    "project_urls": {
        "Download": "https://pypi.org/project/cucu/",
        "Homepage": "https://github.com/dominodatalab/cucu",
        "Source Code": "https://github.com/dominodatalab/cucu"
    },
    "split_keywords": [
        "behave",
        " cucumber",
        " selenium"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a51925ea3fe758eb8067146c7e5b0ef96fe1e79e66415bd4f1d2ca5df76ef0c4",
                "md5": "f6bf1420d96121fee4b4ef35b0146a6f",
                "sha256": "260801a91fedcdf608ba32c45196979e6fe57b34896b3c48828f469b381a4091"
            },
            "downloads": -1,
            "filename": "cucu-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f6bf1420d96121fee4b4ef35b0146a6f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 257072,
            "upload_time": "2024-10-03T00:13:14",
            "upload_time_iso_8601": "2024-10-03T00:13:14.284443Z",
            "url": "https://files.pythonhosted.org/packages/a5/19/25ea3fe758eb8067146c7e5b0ef96fe1e79e66415bd4f1d2ca5df76ef0c4/cucu-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "05a72b9b75cfe31e30d45bd133122526db6e98b2c45b4d82d4e9d3fe76aab1aa",
                "md5": "0bd6985cf9de70970498988c87f6b840",
                "sha256": "2b396daa8fcb7f896a402e6f34e6b8755b3cfe70443dd6b81a4dc87f99af52ed"
            },
            "downloads": -1,
            "filename": "cucu-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "0bd6985cf9de70970498988c87f6b840",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 349278,
            "upload_time": "2024-10-03T00:13:16",
            "upload_time_iso_8601": "2024-10-03T00:13:16.496722Z",
            "url": "https://files.pythonhosted.org/packages/05/a7/2b9b75cfe31e30d45bd133122526db6e98b2c45b4d82d4e9d3fe76aab1aa/cucu-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-03 00:13:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dominodatalab",
    "github_project": "cucu",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "circle": true,
    "lcname": "cucu"
}
        
Elapsed time: 0.69443s