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.1.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.1-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qa_automation2-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 b8f735b1ec4a67ca86de0b8c98b42d235d65556dd30a233dbf519a89c959832a
MD5 1c776e34c1b4507f26d456c8d27acac1
BLAKE2b-256 eab14530cefbab1bd0539c40f8007c2e19cae1af2262dd15f3da877f166f35e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qa_automation2-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7886b4e35e823b6eebaa5b105cbacc95a370eb76d350fd7c34fb72de5290d690
MD5 19cbde7c89560f6017c62191abd297df
BLAKE2b-256 53ad1dfe31f1567cef670dd4ce5d7d0cacd6ac04c5b0012511b45db339ad422b

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