Skip to the content.

Guará

PyPI Downloads

<img src=https://github.com/douglasdcm/guara/raw/main/docs/images/guara.jpg width=”300” height=”300” />

Photo by Mateus Campos Felipe on Unsplash


What is Guará?

Guará is a Python framework designed to simplify UI test automation. Inspired by design patterns like Page Objects, App Actions, and Screenplay, Guará focuses on Page Transactions—encapsulating user interactions (transactions) on web pages, such as Login, Logout, or Form Submissions. It’s not just a tool; it’s a programming pattern that can be adapted to any web driver, not just Selenium.

Why Guará?


Quick Start

Installation

Guará requires Python 3.8+. Install it via pip:

pip install guara

Syntax

Application.at(apage.DoSomething [,with_parameter=value, ...]).asserts(it.Matches, a_condition)

Example in Action

from selenium import webdriver
from pages import home, contact, info, setup
from guara.transaction import Application
from guara import it

def test_sample_web_page():
    # Initialize the Application with a driver
    app = Application(webdriver.Chrome())
    
    # Open the web application
    app.at(setup.OpenApp, url="https://anyhost.com/")
    
    # Change language to Portuguese and assert content
    app.at(home.ChangeToPortuguese).asserts(it.IsEqualTo, content_in_portuguese)

    # Navigate to Info page and assert text presence
    app.at(info.NavigateTo).asserts(it.Contains, "This project was born")

    # Close the web application
    app.at(setup.CloseApp)

Behind the Scenes

The repetitive web driver code is encapsulated in a transaction class:

from guara.transaction import AbstractTransaction

class ChangeToPortuguese(AbstractTransaction):
    def do(self, **kwargs):
        self._driver.find_element(By.CSS_SELECTOR, ".btn:nth-child(3) > button:nth-child(1) > img").click()
        self._driver.find_element(By.CSS_SELECTOR, ".col-md-10").click()
        return self._driver.find_element(By.CSS_SELECTOR, "label:nth-child(1)").text

Key Features

1. Page Transactions

2. Flexible Assertions

3. Cross-Driver Compatibility

4. Asynchronous Execution

5. ChatGPT Assistance


Complete Tutorial

Watch the video

Examples

Explore practical examples in the examples folder.

Contributing

How You Can Help


Why the Name “Guará”?

Guará is the Tupi–Guarani name for the Scarlet Ibis, a vibrant bird native to South America. Just like the bird, Guará stands out for its simplicity and elegance in solving complex UI automation challenges.


Used by

Ready to Dive In?

Start automating with Guará today! Check out the tutorial and explore the examples to see how Guará can simplify your UI testing workflow.


Guará: Simplifying UI automation, one transaction at a time. 🚀