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-0.1.8.tar.gz (9.1 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-0.1.8-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for qa_automation2-0.1.8.tar.gz
Algorithm Hash digest
SHA256 d8989751fa76eac468e348a2a3e7c166048de391e191204927e234104dd1b5b1
MD5 8ca36e44246825eeb6630f96277ce9c0
BLAKE2b-256 3ae06dcee2f204e2c40dd46b8af39ca9bd34919e34928d31f1bcdb3e71859ea6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qa_automation2-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 8.4 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-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 8dc0253edf3ce4ddcd1f0d4680178baeb4d2002407e34306c16fddc42d2205b3
MD5 0c008e0e131c0a78067275c58498065e
BLAKE2b-256 949281da0c2263b0e5b9742ef5c4ee6ef77af7c4592c627ea8fe0e4f6f096d8d

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