ai 开始测试
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import re
|
||||
|
||||
import tidevice
|
||||
import wda
|
||||
from wda import Client
|
||||
from Utils.AiUtils import AiUtils
|
||||
from Utils.LogManager import LogManager
|
||||
@@ -81,11 +82,11 @@ class ControlUtils(object):
|
||||
x, y = AiUtils.findImageInScreen("add", udid)
|
||||
print(x, y)
|
||||
if x > -1:
|
||||
LogManager.info("点赞了",udid)
|
||||
LogManager.info("点赞了", udid)
|
||||
session.click(x // scale, y // scale + 50)
|
||||
return True
|
||||
else:
|
||||
LogManager.info("没有找到目标",udid)
|
||||
LogManager.info("没有找到目标", udid)
|
||||
return False
|
||||
|
||||
# 点击搜索
|
||||
@@ -139,3 +140,31 @@ class ControlUtils(object):
|
||||
else:
|
||||
print("没有找到主页的第一个视频")
|
||||
return False, num
|
||||
|
||||
@classmethod
|
||||
def clickFollow(cls, session, aid):
|
||||
# 1) 含“关注/已关注/Follow/Following”的首个 cell
|
||||
cell_xpath = (
|
||||
'(//XCUIElementTypeCollectionView[@name="TTKSearchCollectionComponent"]'
|
||||
'//XCUIElementTypeCell[.//XCUIElementTypeButton[@name="关注" or @name="Follow" or @name="已关注" or @name="Following"]])[1]'
|
||||
)
|
||||
cell = session.xpath(cell_xpath).get(timeout=5)
|
||||
|
||||
# 2) 先试“用户信息 Button”(label/name 里包含 aid)
|
||||
profile_btn_xpath = (
|
||||
f'{cell_xpath}//XCUIElementTypeButton[contains(@label, "{aid}") or contains(@name, "{aid}")]'
|
||||
)
|
||||
|
||||
try:
|
||||
profile_btn = session.xpath(profile_btn_xpath).get(timeout=3)
|
||||
profile_btn.click()
|
||||
except wda.WDAElementNotFoundError:
|
||||
# 3) 兜底:用“关注”按钮做锚点,向左偏移点击头像/用户名区域
|
||||
follow_btn_xpath = (
|
||||
f'{cell_xpath}//XCUIElementTypeButton[@name="关注" or @name="Follow" or @name="已关注" or @name="Following"]'
|
||||
)
|
||||
follow_btn = session.xpath(follow_btn_xpath).get(timeout=5)
|
||||
rect = follow_btn.bounds
|
||||
left_x = max(1, rect.x - 20)
|
||||
center_y = rect.y + rect.height // 2
|
||||
session.tap(left_x, center_y)
|
||||
|
||||
Reference in New Issue
Block a user