合并代码
This commit is contained in:
@@ -150,6 +150,8 @@ class ControlUtils(object):
|
||||
print("没有找到主页的第一个视频")
|
||||
return False, num
|
||||
|
||||
|
||||
|
||||
@classmethod
|
||||
def clickFollow(cls, session, aid):
|
||||
# 1) 含“关注/已关注/Follow/Following”的首个 cell
|
||||
@@ -177,6 +179,33 @@ class ControlUtils(object):
|
||||
left_x = max(1, rect.x - 20)
|
||||
center_y = rect.y + rect.height // 2
|
||||
session.tap(left_x, center_y)
|
||||
@classmethod
|
||||
def userClickProfile(cls, session, aid):
|
||||
try:
|
||||
user_btn = session.xpath("(//XCUIElementTypeButton[@name='用户' and @visible='true'])[1]")
|
||||
if user_btn:
|
||||
user_btn.click()
|
||||
time.sleep(3)
|
||||
follow_btn = session.xpath(
|
||||
"(//XCUIElementTypeTable//XCUIElementTypeButton[@name='关注' or @name='已关注'])[1]"
|
||||
).get(timeout=5)
|
||||
if follow_btn:
|
||||
x, y, w, h = follow_btn.bounds
|
||||
# 垂直方向中心 + 随机 3~8 像素偏移
|
||||
cy = int(y + h / 2 + random.randint(-8, 8))
|
||||
# 横向往左偏移 80~120 像素之间的随机值
|
||||
cx = int(x - random.randint(80, 120))
|
||||
# 点击
|
||||
session.tap(cx, cy)
|
||||
return True
|
||||
|
||||
return False
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# 随机滑动一点点距离
|
||||
|
||||
Reference in New Issue
Block a user