Skip to main content

Automation test for phone

Project description

QA Automation 2 🚀

Dự án QA Automation2 là một hệ thống tự động hóa kiểm thử cho ứng dụng di động mạnh mẽ, được phát triển dựa trên thư viện uiautomator2. Phiên bản này hỗ trợ tìm kiếm phần tử linh hoạt với nhiều chiến lược (Startswith, Contains, Regex...) và quản lý Log chuyên nghiệp.

📦 Yêu cầu & Cài đặt

  • Python: >= 3.8
  • Android SDK Platform-Tools (adb)

Cài đặt thư viện:

pip install qa_automation2

🚀 Tính năng nổi bật

  • Tìm kiếm phần tử nâng cao: Hỗ trợ Regex ($), Contains (*), StartsWith (^) cho cả Text, Description và Resource ID.
  • Log Rotation: Hệ thống log tự động xoay vòng file (Max 5MB/file, giữ lại 3 file backup).
  • Auto Scroll: Tự động cuộn thông minh để tìm kiếm phần tử theo nhiều hướng (Up, Down, Left, Right).
  • Quản lý thiết bị: Tự động kết nối và lấy thông tin thiết bị.

📖 Hướng dẫn sử dụng

1. Khởi tạo kết nối

from qa_automation2 import qa_connect

# Kết nối thiết bị đầu tiên tìm thấy và lưu log vào thư mục "logs"
automation = qa_connect(log_dir="logs")

# Hoặc kết nối thiết bị cụ thể qua Serial ID
# automation = qa_connect(device_id="RFcn0w...", log_dir="custom_logs")

2. Chiến lược Tìm kiếm (Selector Strategies)

Hàm Find_element và các hàm tương tác hỗ trợ các loại type_ sau để định vị phần tử chính xác hơn:

Loại (type_) Ý nghĩa Ví dụ Code
text Chính xác tuyệt đối text="Login"
text_contains Chứa chuỗi con textContains="Log"
text_startswith Bắt đầu bằng chuỗi textStartsWith="Welcome"
text_matches Biểu thức chính quy (Regex) textMatches="^Log.*"
resource_id ID chính xác resourceId="com.app:id/btn"
resource_id_matches ID theo Regex resourceIdMatches=".*btn_login$"
talkback Content Description chính xác description="Home"
talkback_contains Description chứa chuỗi descriptionContains="ome"
talkback_startswith Description bắt đầu bằng descriptionStartsWith="Hom"
talkback_matches Description theo Regex descriptionMatches="^Hom.*"

3. Ví dụ Code

Click vào một phần tử có chứa chữ "Settings":

automation.Touch(name="Settings", type_="text_contains")

Cuộn xuống tìm phần tử bắt đầu bằng "Chapter 1":

automation.scroll_to_find_element(
    name="Chapter 1", 
    type_="text_startswith", 
    type_scroll="down",
    max_scrolls=10
)

Lấy text của tất cả phần tử con khớp với Regex:

texts = automation.get_all_text_element(name="^[0-9]+$", type_="text_matches")

⚠️ Deprecation Warning

Các hàm sau đây đã lỗi thời và sẽ bị xóa trong phiên bản tới:

  • qa_infor.get_info_element: Đã chuyển sang qautomationcore.qa_automation.get_info_element.
    • Hành động: Vui lòng cập nhật code để sử dụng hàm mới và tránh cảnh báo DeprecationWarning.

📂 Cấu trúc dự án

  • qa_automation2/:
    • qautomationcore.py: Core xử lý chính (Find, Touch, Scroll...).
    • loginfor.py: Quản lý Logging (RotatingFileHandler).
    • adbcore.py: Tương tác ADB.
    • qa_infor.py: (Deprecated) Các tiện ích cũ.
  • logs/: Thư mục lưu trữ log kiểm thử.

🤝 Liên hệ

Mọi thắc mắc hoặc đóng góp vui lòng liên hệ qua email hoặc tạo issue trên repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qa_automation2-1.0.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

qa_automation2-1.0.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file qa_automation2-1.0.0.tar.gz.

File metadata

  • Download URL: qa_automation2-1.0.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for qa_automation2-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8d4d095c3bc79422cc335300ee0f31e35e39277bf380b100883b6602d8f54fd0
MD5 be03454d57a9b0001b7fbcdff81e33a5
BLAKE2b-256 3e6df3c767ad7449d8488b937d12600c9063e8046574d003e38fd615894bc9e7

See more details on using hashes here.

File details

Details for the file qa_automation2-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: qa_automation2-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for qa_automation2-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87cf9c5b14402bacabe053f048e37eb239f4502a581746bb28adb6d7d1414182
MD5 c0883326f0aca199ff6897c5aaf87b15
BLAKE2b-256 383ba8e3a4e1abaeda6d40e9afbd1f19e6c87eb8956a10becfc4d32d000ff2d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page