Skip to content

upasika4/Playwright_Auto_Healing_flaky_errors

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Auto-Healing Test Automation (Python & Playwright)

πŸš€ Overview

This project demonstrates a Self-Healing Automation Framework designed to solve common causes of "flaky" tests in UI automation.

Instead of failing when a selector changes or an element loads slowly, this framework detects the failure, applies a "Smart Wait" or "Backup Strategy" to find the element, and then self-corrects the source code to prevent future failures.

πŸ› οΈ Tech Stack

  • Language: Python
  • Library: Playwright (Sync API)
  • Concept: Design Pattern (Wrapper / Healer)

⚑ Key Features

  1. Smart Locator Recovery: If an ID changes (e.g., #submit -> #new-id), the script automatically tries backup strategies (Text, CSS Classes, Attributes).
  2. Auto-Correction: Once a valid locator is found, the script rewrites its own source code to permanently fix the test.
  3. Resilience to Timing: Handles network lags and late-loading elements automatically.
  4. Stale Element Handling: Detects DOM refreshes and re-queries elements to prevent stale reference errors.

πŸ“‚ Project Structure

  • run_test.py - The main driver script that runs the test scenarios.
  • auto_healer.py - The "Brain" of the project. Contains the logic for detection, diagnosis, and file patching.
  • index.html - A custom dashboard simulation that intentionally creates 3 types of errors (Broken ID, Late Load, Stale Element) to test the healer.

🎯 How It Works

  1. The test attempts to click an element using a primary selector.
  2. If it fails, it catches the exception and enters a Healing Loop.
  3. It iterates through a list of fallbacks (Text, Name, Class).
  4. Upon success, it updates run_test.py with the new working selector.

Created as a Proof of Concept for building resilient automation frameworks.

About

A resilient test automation framework using Python and Playwright that detects UI failures (broken IDs, timing issues) and automatically "heals" the test script by finding backup locators and updating the source code.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors