Skip to content

Commit

Permalink
README to selenium stealth
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasdcm committed Feb 7, 2025
1 parent 4cd6f15 commit 97bcab3
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions examples/web_ui/selenium_stealth/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Selenium Stealth Integration Testing with Guara

This project demonstrates how to integrate **Selenium Stealth** with **Guará's Page Transactions (PT) pattern** to automate interactions with a web page while avoiding bot detection mechanisms.

## Code Breakdown

### **Imports**
- `selenium.webdriver`: Manages browser automation.
- `selenium_stealth.stealth`: Helps bypass bot detection mechanisms.
- `guara.transaction.Application`: Manages transactions within the Guará framework.
- `guara.it`: Provides assertion utilities.

---

## **Test Class: `TestSeleniumStealthIntegration`**
This class automates interactions with a **local web page** using **Selenium Stealth** to evade detection.

### **Setup Method (`setup_method`)**
1. Configures **Chrome WebDriver** with options to **disable automation detection** and run in headless mode.
2. Applies **Selenium Stealth settings** to mimic a real user's environment by:
- Setting browser languages.
- Spoofing vendor and platform details.
- Modifying WebGL renderer settings.
3. Initializes a **Guará Application** instance with the configured WebDriver.
4. Opens a web page (`https://example.com`) using `setup.OpenStealthBrowser`.

### **Teardown Method (`teardown_method`)**
- Closes the browser after each test using `setup.CloseStealthBrowser`.

---

## **Test Case: `test_local_page`**
This test verifies that text input is successfully processed on the web page.
1. Defines a list of sample texts.
2. Selects a **random text value** for submission.
3. Submits the text using `home.SubmitSeleniumStealth`.
4. **Assertions:**
- Ensures the page contains "Example Domain" after text submission.
- Ensures the result is **not equal** to an arbitrary incorrect value ("Any").

---

## **Summary**
- The test automates interactions with a **web page** while avoiding bot detection.
- Uses **Selenium Stealth** to make browser automation **less detectable**.
- Implements the **Guará PT pattern** for structured automation.
- Uses **randomized text selection** to enhance test variability.

0 comments on commit 97bcab3

Please sign in to comment.