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.2.tar.gz (9.3 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.2-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qa_automation2-1.0.2.tar.gz
  • Upload date:
  • Size: 9.3 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.2.tar.gz
Algorithm Hash digest
SHA256 e1da0fe8861bf2810f8d7148c5eab2b2963ed99bae16618d85897324bf74b896
MD5 fc1ae561c5fef015fc25c78102734cca
BLAKE2b-256 bd02f2c054a954e1701ffabe8ff2ed79cb47c8fdfc85c4b0a1f9406c3c88a305

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qa_automation2-1.0.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ea65b7db7fba9880cf74a0f1f49cf951565df63cd945fcb31952077b8792b3e9
MD5 f3f5adb71f4fdf7d7b0bc44e29d07b4e
BLAKE2b-256 13d5c6cf0a2981f72f1d7fcc41a3d4ee744241026dec39485281cf5aa92773c7

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