42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
# coding=utf-8
|
|
import asyncio
|
|
import uiautomator2 as u2
|
|
import os
|
|
import sys
|
|
import uuid
|
|
|
|
project_root = r"D:\dsWork\aiData"
|
|
if project_root not in sys.path:
|
|
sys.path.append(project_root)
|
|
|
|
from Apps.AiTeJiYiChong import Kit
|
|
from Apps.AiTeJiYiChong.Kit import take_screenshot, read_image
|
|
from Config.Config import TEMP_IMAGE_DIR
|
|
|
|
async def test_click_and_detail():
|
|
d = u2.connect()
|
|
image_uuid = str(uuid.uuid4())
|
|
print(f"Taking initial screenshot...")
|
|
screenshot_path = take_screenshot(d, image_uuid, save_dir=TEMP_IMAGE_DIR)
|
|
|
|
print(f"Analyzing cards in {screenshot_path}...")
|
|
json_data = Kit.crop_cards_from_image(screenshot_path)
|
|
|
|
if json_data and json_data.get("cards"):
|
|
first_card = json_data["cards"][0]
|
|
click_x, click_y = first_card["click_point"]
|
|
print(f"Clicking card at ({click_x}, {click_y})...")
|
|
d.click(click_x, click_y)
|
|
|
|
print("Waiting for detail page...")
|
|
await asyncio.sleep(5)
|
|
|
|
detail_uuid = f"detail_{image_uuid}"
|
|
detail_path = take_screenshot(d, detail_uuid, save_dir=TEMP_IMAGE_DIR)
|
|
print(f"Detail page screenshot: {detail_path}")
|
|
else:
|
|
print("No cards found on current screen.")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(test_click_and_detail())
|