合并代码

This commit is contained in:
2025-11-05 17:08:08 +08:00
2 changed files with 64 additions and 31 deletions

View File

@@ -104,6 +104,52 @@ class ControlUtils(object):
print(e)
return False
@classmethod
def isClickBackEnabled(cls, session: Client):
try:
back = session.xpath(
# ① 常见中文文案
"//*[@label='返回' or @label='返回上一屏幕']"
" | "
# ② 英文 / 内部 name / 图标 label 的按钮(仅限 Button且可见
"//XCUIElementTypeButton[@visible='true' and ("
"@name='Back' or @label='Back' or " # 英文
"@name='返回' or @label='返回' or " # 中文
"@label='返回上一屏幕' or " # 中文另一种
"@name='returnButton' or"
"@name='nav_bar_start_back' or " # 内部常见 name
"(@name='TTKProfileNavBarBaseItemComponent' and @label='IconChevronLeftOffsetLTR')" # 你给的特例
")]"
)
if back.exists:
return True
elif session.xpath("//*[@name='nav_bar_start_back']").exists:
back = session.xpath("//*[@name='nav_bar_start_back']")
if back.exists:
return True
elif session.xpath(
"//Window[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]").exists:
back = session.xpath(
"//Window[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]/Other[1]")
if back.exists:
return True
elif session.xpath(
"(//XCUIElementTypeOther[@y='20' and @height='44']//XCUIElementTypeButton[@visible='true'])[1]").exists:
back = session.xpath(
"(//XCUIElementTypeOther[@y='20' and @height='44']//XCUIElementTypeButton[@visible='true'])[1]")
if back.exists:
return True
else:
return False
except Exception as e:
print(e)
return False
# 点赞
@classmethod
def clickLike(cls, session: Client, udid):