pyautotk 0.4.0
Page Object framework helper
Requires Python: >=3.8

# PyAutoTk Framework Documentation

**PyAutoTk** is a modular and extensible automation framework designed to simplify the process of creating, managing, and executing automation scripts for web platforms.

## Getting Started

You have two options to get started with PyAutoTk:

1. **Cloning the repository and installing as a developer:**

```bash
git clone https://github.com/brailog/PyAutoTk.git
cd PyAutoTk
pip install -e .
```
2. **Installing PyAutoTk from PyPI:**
```bash
pip install pyautotk
```

Once installed, you can begin using the framework to automate your web application.

## When to Use PyAutoTk?

PyAutoTk is ideal for developers and QA engineers who need a structured framework for automating:

- Web application testing
- Data scraping from web applications
- Functional testing of UI components

PyAutoTk leverages Selenium for web automation, providing a flexible and powerful way to interact with complex UI elements. As the framework evolves, there will be support for mobile platforms as well.

## How to Use PyAutoTk

Let's walk through an example to help you get started with PyAutoTk.
### Example Script

Create a new file called `pyautotk_example.py` and copy the following code:

```python
import time
from pyautotk.elements.widget import Widget
from pyautotk.elements.helpers.session_helpers import browser_session
from pyautotk.core.exceptions import ElementNotVisibleException

@browser_session(url="https://www.youtube.com/")
def watch_shorts(session, swipe_times=5):
    Widget(session, text="Shorts").click()
    en_button_down = Widget(session, aria_label="Next video")
    pt_button_down = Widget(session, aria_label="Proximo vídeo")
    for swipe in range(swipe_times):
        try:
            en_button_down.wait_for()
            en_button_down.click()
        except ElementNotVisibleException:
            pt_button_down.wait_for()
            pt_button_down.click()
        time.sleep(1)

watch_shorts()
```
Save the file and run the script using the following command:
```bash
python3 pyautotk_example.py
```

## Explanation of the Example

- **Importing Key Components:** The example imports `browser_session` to create a session with the browser and `Widget` to interact with UI elements.
- **`browser_session` Decorator:** This decorator is essential to open the browser and navigate to the specified URL. In this case, we navigate to YouTube to view "Shorts". Optional parameters such as browser type, headless mode, and maximization can be set globally using `config_loader`.
- **Handling Language Differences:** The example demonstrates how to handle potential language differences by creating two Widget instances — one for English (`Next video`) and another for Portuguese (`Proximo vídeo`), ensuring the script works regardless of the browser language.


### Global Configuration Example

You can configure PyAutoTk globally using the config_loader. This allows you to adjust logging levels, browser types, and other settings.
```python
from pyautotk.core.config_loader import config

config.log_level = "DEBUG"
config.browser_type = "firefox"
config.headless_mode = False
config.maximize_browser = True
```
For more details, refer to the official documentation [here](https://pyautotk.readthedocs.io/en/latest/)