临时提交
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import tidevice
|
||||
from wda import Client
|
||||
|
||||
from Entity.Variables import tikTokApp
|
||||
@@ -7,13 +8,47 @@ from Utils.LogManager import LogManager
|
||||
# 页面控制工具类
|
||||
class ControlUtils(object):
|
||||
|
||||
# 获取设备上的app列表
|
||||
@classmethod
|
||||
def getDeviceAppList(self, udid):
|
||||
device = tidevice.Device(udid)
|
||||
# 获取已安装的应用列表
|
||||
apps = []
|
||||
for app in device.installation.iter_installed():
|
||||
apps.append({
|
||||
"name": app.get("CFBundleDisplayName", "Unknown"),
|
||||
"bundleId": app.get("CFBundleIdentifier", "Unknown"),
|
||||
"version": app.get("CFBundleShortVersionString", "Unknown"),
|
||||
"path": app.get("Path", "Unknown")
|
||||
})
|
||||
|
||||
# 筛选非系统级应用(过滤掉以 com.apple 开头的系统应用)
|
||||
noSystemApps = [app for app in apps if not app["bundleId"].startswith("com.apple")]
|
||||
return noSystemApps
|
||||
|
||||
# 打开Tik Tok
|
||||
@classmethod
|
||||
def openTikTok(cls, session: Client):
|
||||
def openTikTok(cls, session: Client, udid):
|
||||
apps = cls.getDeviceAppList(udid)
|
||||
tk = ""
|
||||
for app in apps:
|
||||
if app.get("name", "") == "TikTok":
|
||||
tk = app.get("bundleId", "")
|
||||
|
||||
currentApp = session.app_current()
|
||||
if currentApp != tikTokApp:
|
||||
if currentApp != tk:
|
||||
session.app_start(tikTokApp)
|
||||
|
||||
# 关闭Tik Tok
|
||||
@classmethod
|
||||
def closeTikTok(cls, session: Client, udid):
|
||||
apps = cls.getDeviceAppList(udid)
|
||||
tk = ""
|
||||
for app in apps:
|
||||
if app.get("name", "") == "TikTok":
|
||||
tk = app.get("bundleId", "")
|
||||
session.app_stop(tk)
|
||||
|
||||
# 返回
|
||||
@classmethod
|
||||
def clickBack(cls, session: Client):
|
||||
@@ -63,5 +98,16 @@ class ControlUtils(object):
|
||||
# return False
|
||||
|
||||
|
||||
# 点击搜索
|
||||
@classmethod
|
||||
def clickSearch(cls, session: Client):
|
||||
obj = session.xpath("//*[@name='搜索']")
|
||||
try:
|
||||
if obj.label == "搜索":
|
||||
return obj
|
||||
else:
|
||||
return None
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return None
|
||||
|
||||
# ControlUtils.backAction("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")
|
||||
Reference in New Issue
Block a user