# PyUI Automation
A powerful, cross-platform Python library for desktop UI testing and automation with advanced features including visual testing, performance monitoring, and accessibility checking.
## Features
- 🖥️ Cross-Platform Support (Windows, Linux, macOS)
- 🔍 Multiple Element Finding Strategies
- 🖱️ Advanced Input Simulation
- 📸 Visual Testing and Comparison
- ⚡ Performance Monitoring and Testing
- ♿ Accessibility Testing
- 🔄 Application Management
- 📊 Comprehensive Reporting
## Quick Start
```python
from pyui_automation import UIAutomation
# Initialize automation
ui = UIAutomation()
# Find and interact with elements
button = ui.find_element(by="name", value="Submit")
button.click()
# Visual testing
ui.take_screenshot("before.png")
button.click()
ui.take_screenshot("after.png")
ui.compare_images("before.png", "after.png", threshold=0.95)
# OCR capabilities
text = ui.recognize_text("screenshot.png")
print(f"Found text: {text}")
# Performance monitoring
with ui.measure_performance() as perf:
button.click()
print(f"Click took: {perf.duration}ms")
# Accessibility testing
violations = ui.check_accessibility(button)
for v in violations:
print(f"Violation: {v.description}")
```
## Installation
```bash
# Install required dependencies
pip install -r requirements.txt
# Install development dependencies
pip install -r requirements-dev.txt
```
## Examples
### Finding Elements
```python
# Find by name
element = ui.find_element(by="name", value="Submit")
# Find by ID
element = ui.find_element(by="id", value="submit-button")
# Find by class name
element = ui.find_element(by="class", value="btn-primary")
# Find with timeout
element = ui.find_element(by="name", value="Submit", timeout=10)
# Find multiple elements
elements = ui.find_elements(by="class", value="list-item")
```
### Mouse and Keyboard Input
```python
# Mouse actions
ui.click(x=100, y=200)
ui.double_click(x=100, y=200)
ui.right_click(x=100, y=200)
ui.drag_and_drop(start_x=100, start_y=200, end_x=300, end_y=400)
# Keyboard input
ui.type_text("Hello World")
ui.press_key("enter")
ui.press_keys(["ctrl", "c"])
```
### Visual Testing
```python
# Basic screenshot comparison
ui.take_screenshot("baseline.png")
# ... perform actions ...
ui.take_screenshot("current.png")
diff = ui.compare_images("baseline.png", "current.png")
assert diff.similarity > 0.95
# Region-based comparison
region = (100, 100, 200, 200) # x, y, width, height
ui.take_screenshot("region.png", region=region)
# With masking
mask = ui.create_mask()
mask.add_region((100, 100, 200, 200))
diff = ui.compare_images("baseline.png", "current.png", mask=mask)
```
### OCR and Text Recognition
```python
# Basic text recognition
text = ui.recognize_text("screenshot.png")
# With region
region = (100, 100, 200, 200)
text = ui.recognize_text("screenshot.png", region=region)
# With confidence threshold
text = ui.recognize_text("screenshot.png", confidence=0.8)
# Find text location
locations = ui.find_text("Submit", "screenshot.png")
for x, y in locations:
print(f"Found 'Submit' at ({x}, {y})")
```
### Performance Testing
```python
# Basic performance measurement
with ui.measure_performance() as perf:
button.click()
print(f"Operation took: {perf.duration}ms")
# Custom metrics
with ui.measure_performance() as perf:
perf.start_metric("database")
# ... database operations ...
perf.end_metric("database")
perf.start_metric("rendering")
# ... rendering operations ...
perf.end_metric("rendering")
print(f"Database: {perf.get_metric('database')}ms")
print(f"Rendering: {perf.get_metric('rendering')}ms")
```
### Accessibility Testing
```python
# Check single element
violations = ui.check_accessibility(button)
# Check entire window
window = ui.get_active_window()
violations = ui.check_accessibility(window, recursive=True)
# With custom rules
rules = {
"contrast": {"min_ratio": 4.5},
"text_size": {"min_size": 12}
}
violations = ui.check_accessibility(button, rules=rules)
```
## Code Coverage
```
---------- coverage: platform win32, python 3.12.0-final-0 -----------
Name Stmts Miss Cover
----------------------------------------------------------
pyui_automation/__init__.py 8 0 100%
pyui_automation/accessibility.py 136 8 94%
pyui_automation/application.py 138 62 55%
pyui_automation/backends/__init__.py 14 7 50%
pyui_automation/backends/base.py 33 0 100%
pyui_automation/backends/linux.py 75 58 23%
pyui_automation/backends/macos.py 94 76 19%
pyui_automation/backends/windows.py 218 56 74%
pyui_automation/core.py 246 246 0%
pyui_automation/core/__init__.py 5 0 100%
pyui_automation/core/config.py 28 0 100%
pyui_automation/core/factory.py 37 2 95%
pyui_automation/core/session.py 74 13 82%
pyui_automation/core/utils.py 36 24 33%
pyui_automation/di.py 29 0 100%
pyui_automation/elements.py 83 83 0%
pyui_automation/elements/__init__.py 5 0 100%
pyui_automation/elements/base.py 40 3 92%
pyui_automation/elements/button.py 13 0 100%
pyui_automation/elements/input.py 25 11 56%
pyui_automation/elements/window.py 25 0 100%
pyui_automation/exceptions.py 11 0 100%
pyui_automation/input.py 202 106 48%
pyui_automation/logging.py 39 0 100%
pyui_automation/ocr.py 79 15 81%
pyui_automation/optimization.py 75 75 0%
pyui_automation/performance.py 142 45 68%
pyui_automation/utils/__init__.py 4 0 100%
pyui_automation/utils/file.py 47 33 30%
pyui_automation/utils/image.py 101 36 64%
pyui_automation/utils/validation.py 31 0 100%
pyui_automation/visual.py 168 25 85%
pyui_automation/wait.py 44 23 48%
----------------------------------------------------------
TOTAL 2305 1007 56%
```
### Coverage Highlights
🟢 **High Coverage (90-100%)**
- Core Components: `exceptions.py`, `logging.py`, `validation.py`, `di.py`
- Base Classes: `backends/base.py`, `elements/button.py`, `elements/window.py`
- Configuration: `core/config.py`, `core/factory.py`
- Accessibility Testing: `accessibility.py` (94%)
🟡 **Medium Coverage (50-89%)**
- Visual Testing: `visual.py` (85%)
- Core Session: `core/session.py` (82%)
- OCR: `ocr.py` (81%)
- Windows Backend: `backends/windows.py` (74%)
- Performance: `performance.py` (68%)
- Image Utils: `utils/image.py` (64%)
- Input Elements: `elements/input.py` (56%)
- Application: `application.py` (55%)
🔴 **Low Coverage (<50%)**
- Core Implementation: `core.py` (0%)
- Elements Base: `elements.py` (0%)
- Optimization: `optimization.py` (0%)
- Platform Backends: `linux.py` (23%), `macos.py` (19%)
- File Utils: `utils/file.py` (30%)
- Core Utils: `core/utils.py` (33%)
- Input Handling: `input.py` (48%), `wait.py` (48%)
### Areas for Improvement
1. Core Implementation (`core.py`, `elements.py`): Need comprehensive test coverage
2. Platform Backends: Improve Linux and macOS testing
3. Input Handling: Add more test cases for input simulation and wait conditions
4. Optimization: Implement test suite for performance optimization module
## Project Structure
```
pyui_automation/
├── core/
│ ├── config.py # Configuration management
│ ├── factory.py # Component factories
│ ├── session.py # Main automation session
│ └── utils.py # Core utilities
├── elements/
│ ├── base.py # Base element class
│ ├── window.py # Window element
│ └── controls/ # UI control elements
├── backends/
│ ├── windows.py # Windows implementation
│ ├── linux.py # Linux implementation
│ └── macos.py # macOS implementation
└── utils/
├── image.py # Image processing
├── ocr.py # Text recognition
└── performance.py # Performance monitoring
```
## Testing
```bash
# Run all tests
pytest
# Run with coverage
pytest --cov=pyui_automation
# Run specific test module
pytest tests/test_visual.py
# Run with verbose output
pytest -v
# Run tests matching pattern
pytest -k "test_visual or test_ocr"
```
## Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Run tests and ensure coverage
5. Submit a pull request
## License
This project is licensed under the MIT License - see the LICENSE file for details.
Raw data
{
"_id": null,
"home_page": "https://github.com/DaymaNKinG990/pyui_automation",
"name": "pyui-automation",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "ui automation, testing, gui testing, automation, accessibility testing, visual testing, performance testing, ocr, cross-platform",
"author": "Ravil Shakerov",
"author_email": "your.email@example.com",
"download_url": "https://files.pythonhosted.org/packages/7b/28/b672a7f16785f6ac81073a1f30e5e19c10d1bd1bb7f77a1153d52c90bf35/pyui_automation-0.1.0.tar.gz",
"platform": null,
"description": "# PyUI Automation\r\n\r\nA powerful, cross-platform Python library for desktop UI testing and automation with advanced features including visual testing, performance monitoring, and accessibility checking.\r\n\r\n## Features\r\n\r\n- \ud83d\udda5\ufe0f Cross-Platform Support (Windows, Linux, macOS)\r\n- \ud83d\udd0d Multiple Element Finding Strategies\r\n- \ud83d\uddb1\ufe0f Advanced Input Simulation\r\n- \ud83d\udcf8 Visual Testing and Comparison\r\n- \u26a1 Performance Monitoring and Testing\r\n- \u267f Accessibility Testing\r\n- \ud83d\udd04 Application Management\r\n- \ud83d\udcca Comprehensive Reporting\r\n\r\n## Quick Start\r\n\r\n```python\r\nfrom pyui_automation import UIAutomation\r\n\r\n# Initialize automation\r\nui = UIAutomation()\r\n\r\n# Find and interact with elements\r\nbutton = ui.find_element(by=\"name\", value=\"Submit\")\r\nbutton.click()\r\n\r\n# Visual testing\r\nui.take_screenshot(\"before.png\")\r\nbutton.click()\r\nui.take_screenshot(\"after.png\")\r\nui.compare_images(\"before.png\", \"after.png\", threshold=0.95)\r\n\r\n# OCR capabilities\r\ntext = ui.recognize_text(\"screenshot.png\")\r\nprint(f\"Found text: {text}\")\r\n\r\n# Performance monitoring\r\nwith ui.measure_performance() as perf:\r\n button.click()\r\nprint(f\"Click took: {perf.duration}ms\")\r\n\r\n# Accessibility testing\r\nviolations = ui.check_accessibility(button)\r\nfor v in violations:\r\n print(f\"Violation: {v.description}\")\r\n```\r\n\r\n## Installation\r\n\r\n```bash\r\n# Install required dependencies\r\npip install -r requirements.txt\r\n\r\n# Install development dependencies\r\npip install -r requirements-dev.txt\r\n```\r\n\r\n## Examples\r\n\r\n### Finding Elements\r\n\r\n```python\r\n# Find by name\r\nelement = ui.find_element(by=\"name\", value=\"Submit\")\r\n\r\n# Find by ID\r\nelement = ui.find_element(by=\"id\", value=\"submit-button\")\r\n\r\n# Find by class name\r\nelement = ui.find_element(by=\"class\", value=\"btn-primary\")\r\n\r\n# Find with timeout\r\nelement = ui.find_element(by=\"name\", value=\"Submit\", timeout=10)\r\n\r\n# Find multiple elements\r\nelements = ui.find_elements(by=\"class\", value=\"list-item\")\r\n```\r\n\r\n### Mouse and Keyboard Input\r\n\r\n```python\r\n# Mouse actions\r\nui.click(x=100, y=200)\r\nui.double_click(x=100, y=200)\r\nui.right_click(x=100, y=200)\r\nui.drag_and_drop(start_x=100, start_y=200, end_x=300, end_y=400)\r\n\r\n# Keyboard input\r\nui.type_text(\"Hello World\")\r\nui.press_key(\"enter\")\r\nui.press_keys([\"ctrl\", \"c\"])\r\n```\r\n\r\n### Visual Testing\r\n\r\n```python\r\n# Basic screenshot comparison\r\nui.take_screenshot(\"baseline.png\")\r\n# ... perform actions ...\r\nui.take_screenshot(\"current.png\")\r\ndiff = ui.compare_images(\"baseline.png\", \"current.png\")\r\nassert diff.similarity > 0.95\r\n\r\n# Region-based comparison\r\nregion = (100, 100, 200, 200) # x, y, width, height\r\nui.take_screenshot(\"region.png\", region=region)\r\n\r\n# With masking\r\nmask = ui.create_mask()\r\nmask.add_region((100, 100, 200, 200))\r\ndiff = ui.compare_images(\"baseline.png\", \"current.png\", mask=mask)\r\n```\r\n\r\n### OCR and Text Recognition\r\n\r\n```python\r\n# Basic text recognition\r\ntext = ui.recognize_text(\"screenshot.png\")\r\n\r\n# With region\r\nregion = (100, 100, 200, 200)\r\ntext = ui.recognize_text(\"screenshot.png\", region=region)\r\n\r\n# With confidence threshold\r\ntext = ui.recognize_text(\"screenshot.png\", confidence=0.8)\r\n\r\n# Find text location\r\nlocations = ui.find_text(\"Submit\", \"screenshot.png\")\r\nfor x, y in locations:\r\n print(f\"Found 'Submit' at ({x}, {y})\")\r\n```\r\n\r\n### Performance Testing\r\n\r\n```python\r\n# Basic performance measurement\r\nwith ui.measure_performance() as perf:\r\n button.click()\r\nprint(f\"Operation took: {perf.duration}ms\")\r\n\r\n# Custom metrics\r\nwith ui.measure_performance() as perf:\r\n perf.start_metric(\"database\")\r\n # ... database operations ...\r\n perf.end_metric(\"database\")\r\n \r\n perf.start_metric(\"rendering\")\r\n # ... rendering operations ...\r\n perf.end_metric(\"rendering\")\r\n\r\nprint(f\"Database: {perf.get_metric('database')}ms\")\r\nprint(f\"Rendering: {perf.get_metric('rendering')}ms\")\r\n```\r\n\r\n### Accessibility Testing\r\n\r\n```python\r\n# Check single element\r\nviolations = ui.check_accessibility(button)\r\n\r\n# Check entire window\r\nwindow = ui.get_active_window()\r\nviolations = ui.check_accessibility(window, recursive=True)\r\n\r\n# With custom rules\r\nrules = {\r\n \"contrast\": {\"min_ratio\": 4.5},\r\n \"text_size\": {\"min_size\": 12}\r\n}\r\nviolations = ui.check_accessibility(button, rules=rules)\r\n```\r\n\r\n## Code Coverage\r\n\r\n```\r\n---------- coverage: platform win32, python 3.12.0-final-0 -----------\r\nName Stmts Miss Cover\r\n----------------------------------------------------------\r\npyui_automation/__init__.py 8 0 100%\r\npyui_automation/accessibility.py 136 8 94%\r\npyui_automation/application.py 138 62 55%\r\npyui_automation/backends/__init__.py 14 7 50%\r\npyui_automation/backends/base.py 33 0 100%\r\npyui_automation/backends/linux.py 75 58 23%\r\npyui_automation/backends/macos.py 94 76 19%\r\npyui_automation/backends/windows.py 218 56 74%\r\npyui_automation/core.py 246 246 0%\r\npyui_automation/core/__init__.py 5 0 100%\r\npyui_automation/core/config.py 28 0 100%\r\npyui_automation/core/factory.py 37 2 95%\r\npyui_automation/core/session.py 74 13 82%\r\npyui_automation/core/utils.py 36 24 33%\r\npyui_automation/di.py 29 0 100%\r\npyui_automation/elements.py 83 83 0%\r\npyui_automation/elements/__init__.py 5 0 100%\r\npyui_automation/elements/base.py 40 3 92%\r\npyui_automation/elements/button.py 13 0 100%\r\npyui_automation/elements/input.py 25 11 56%\r\npyui_automation/elements/window.py 25 0 100%\r\npyui_automation/exceptions.py 11 0 100%\r\npyui_automation/input.py 202 106 48%\r\npyui_automation/logging.py 39 0 100%\r\npyui_automation/ocr.py 79 15 81%\r\npyui_automation/optimization.py 75 75 0%\r\npyui_automation/performance.py 142 45 68%\r\npyui_automation/utils/__init__.py 4 0 100%\r\npyui_automation/utils/file.py 47 33 30%\r\npyui_automation/utils/image.py 101 36 64%\r\npyui_automation/utils/validation.py 31 0 100%\r\npyui_automation/visual.py 168 25 85%\r\npyui_automation/wait.py 44 23 48%\r\n----------------------------------------------------------\r\nTOTAL 2305 1007 56%\r\n```\r\n\r\n### Coverage Highlights\r\n\r\n\ud83d\udfe2 **High Coverage (90-100%)**\r\n- Core Components: `exceptions.py`, `logging.py`, `validation.py`, `di.py`\r\n- Base Classes: `backends/base.py`, `elements/button.py`, `elements/window.py`\r\n- Configuration: `core/config.py`, `core/factory.py`\r\n- Accessibility Testing: `accessibility.py` (94%)\r\n\r\n\ud83d\udfe1 **Medium Coverage (50-89%)**\r\n- Visual Testing: `visual.py` (85%)\r\n- Core Session: `core/session.py` (82%)\r\n- OCR: `ocr.py` (81%)\r\n- Windows Backend: `backends/windows.py` (74%)\r\n- Performance: `performance.py` (68%)\r\n- Image Utils: `utils/image.py` (64%)\r\n- Input Elements: `elements/input.py` (56%)\r\n- Application: `application.py` (55%)\r\n\r\n\ud83d\udd34 **Low Coverage (<50%)**\r\n- Core Implementation: `core.py` (0%)\r\n- Elements Base: `elements.py` (0%)\r\n- Optimization: `optimization.py` (0%)\r\n- Platform Backends: `linux.py` (23%), `macos.py` (19%)\r\n- File Utils: `utils/file.py` (30%)\r\n- Core Utils: `core/utils.py` (33%)\r\n- Input Handling: `input.py` (48%), `wait.py` (48%)\r\n\r\n### Areas for Improvement\r\n1. Core Implementation (`core.py`, `elements.py`): Need comprehensive test coverage\r\n2. Platform Backends: Improve Linux and macOS testing\r\n3. Input Handling: Add more test cases for input simulation and wait conditions\r\n4. Optimization: Implement test suite for performance optimization module\r\n\r\n## Project Structure\r\n\r\n```\r\npyui_automation/\r\n\u251c\u2500\u2500 core/\r\n\u2502 \u251c\u2500\u2500 config.py # Configuration management\r\n\u2502 \u251c\u2500\u2500 factory.py # Component factories\r\n\u2502 \u251c\u2500\u2500 session.py # Main automation session\r\n\u2502 \u2514\u2500\u2500 utils.py # Core utilities\r\n\u251c\u2500\u2500 elements/\r\n\u2502 \u251c\u2500\u2500 base.py # Base element class\r\n\u2502 \u251c\u2500\u2500 window.py # Window element\r\n\u2502 \u2514\u2500\u2500 controls/ # UI control elements\r\n\u251c\u2500\u2500 backends/\r\n\u2502 \u251c\u2500\u2500 windows.py # Windows implementation\r\n\u2502 \u251c\u2500\u2500 linux.py # Linux implementation\r\n\u2502 \u2514\u2500\u2500 macos.py # macOS implementation\r\n\u2514\u2500\u2500 utils/\r\n \u251c\u2500\u2500 image.py # Image processing\r\n \u251c\u2500\u2500 ocr.py # Text recognition\r\n \u2514\u2500\u2500 performance.py # Performance monitoring\r\n```\r\n\r\n## Testing\r\n\r\n```bash\r\n# Run all tests\r\npytest\r\n\r\n# Run with coverage\r\npytest --cov=pyui_automation\r\n\r\n# Run specific test module\r\npytest tests/test_visual.py\r\n\r\n# Run with verbose output\r\npytest -v\r\n\r\n# Run tests matching pattern\r\npytest -k \"test_visual or test_ocr\"\r\n```\r\n\r\n## Contributing\r\n\r\n1. Fork the repository\r\n2. Create a feature branch\r\n3. Make your changes\r\n4. Run tests and ensure coverage\r\n5. Submit a pull request\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License - see the LICENSE file for details.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A powerful, cross-platform Python library for desktop UI testing and automation",
"version": "0.1.0",
"project_urls": {
"Bug Tracker": "https://github.com/DaymaNKinG990/pyui_automation/issues",
"Documentation": "https://github.com/DaymaNKinG990/pyui_automation#readme",
"Homepage": "https://github.com/DaymaNKinG990/pyui_automation",
"Source Code": "https://github.com/DaymaNKinG990/pyui_automation"
},
"split_keywords": [
"ui automation",
" testing",
" gui testing",
" automation",
" accessibility testing",
" visual testing",
" performance testing",
" ocr",
" cross-platform"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "d9a0f8e934a5b6570e053d0f4fe9645f9c8d38871ddc4bec141dec402501ddd4",
"md5": "eaf85267115053f18a36d5315d3e9a77",
"sha256": "0910100a0ce6dfdc5c4c261dc7a1776e64da456b99c18c63994833b3bc1945f1"
},
"downloads": -1,
"filename": "pyui_automation-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "eaf85267115053f18a36d5315d3e9a77",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 48513,
"upload_time": "2024-12-11T20:40:13",
"upload_time_iso_8601": "2024-12-11T20:40:13.943062Z",
"url": "https://files.pythonhosted.org/packages/d9/a0/f8e934a5b6570e053d0f4fe9645f9c8d38871ddc4bec141dec402501ddd4/pyui_automation-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7b28b672a7f16785f6ac81073a1f30e5e19c10d1bd1bb7f77a1153d52c90bf35",
"md5": "12b8d71b0aa293ed16a80cc3188d1d57",
"sha256": "93f73339d769ec9886ef7460e23a3c83c97b1347bbe9ad2b660b80232b941ce0"
},
"downloads": -1,
"filename": "pyui_automation-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "12b8d71b0aa293ed16a80cc3188d1d57",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 65393,
"upload_time": "2024-12-11T20:40:17",
"upload_time_iso_8601": "2024-12-11T20:40:17.199137Z",
"url": "https://files.pythonhosted.org/packages/7b/28/b672a7f16785f6ac81073a1f30e5e19c10d1bd1bb7f77a1153d52c90bf35/pyui_automation-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-11 20:40:17",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "DaymaNKinG990",
"github_project": "pyui_automation",
"github_not_found": true,
"lcname": "pyui-automation"
}