ai 开始测试

This commit is contained in:
2025-08-28 16:24:32 +08:00
parent df2713e62b
commit bd9b3c5255
5 changed files with 69 additions and 37 deletions

59
.idea/workspace.xml generated
View File

@@ -6,8 +6,10 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="eceeff5e-51c1-459c-a911-d21ec090a423" name="Changes" comment="ai 开始测试"> <list default="true" id="eceeff5e-51c1-459c-a911-d21ec090a423" name="Changes" comment="ai 开始测试">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Entity/Variables.py" beforeDir="false" afterPath="$PROJECT_DIR$/Entity/Variables.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/Utils/ControlUtils.py" beforeDir="false" afterPath="$PROJECT_DIR$/Utils/ControlUtils.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Utils/Requester.py" beforeDir="false" afterPath="$PROJECT_DIR$/Utils/Requester.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/resources/03cb0d61638ab919e9c9c5e016b969ff40925b0c/bgv.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/833c034d29ee6b79e1dfd88dc1d454f3da1e8a3d/bgv.png" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/script/ScriptManager.py" beforeDir="false" afterPath="$PROJECT_DIR$/script/ScriptManager.py" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -47,25 +49,25 @@
<option name="hideEmptyMiddlePackages" value="true" /> <option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" /> <option name="showLibraryContents" value="true" />
</component> </component>
<component name="PropertiesComponent"><![CDATA[{ <component name="PropertiesComponent">{
"keyToString": { &quot;keyToString&quot;: {
"Python.123.executor": "Run", &quot;Python.123.executor&quot;: &quot;Run&quot;,
"Python.Main.executor": "Run", &quot;Python.Main.executor&quot;: &quot;Run&quot;,
"RunOnceActivity.ShowReadmeOnStart": "true", &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
"SHARE_PROJECT_CONFIGURATION_FILES": "true", &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
"git-widget-placeholder": "main", &quot;git-widget-placeholder&quot;: &quot;main&quot;,
"javascript.nodejs.core.library.configured.version": "20.17.0", &quot;javascript.nodejs.core.library.configured.version&quot;: &quot;20.17.0&quot;,
"javascript.nodejs.core.library.typings.version": "20.17.58", &quot;javascript.nodejs.core.library.typings.version&quot;: &quot;20.17.58&quot;,
"last_opened_file_path": "F:/company code/AI item/20250820/iOSAI", &quot;last_opened_file_path&quot;: &quot;F:/company code/AI item/20250820/iOSAI&quot;,
"node.js.detected.package.eslint": "true", &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
"node.js.detected.package.tslint": "true", &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
"node.js.selected.package.eslint": "(autodetect)", &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
"node.js.selected.package.tslint": "(autodetect)", &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
"nodejs_package_manager_path": "npm", &quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
"settings.editor.selected.configurable": "com.gitee.ui.GiteeSettingsConfigurable", &quot;settings.editor.selected.configurable&quot;: &quot;com.gitee.ui.GiteeSettingsConfigurable&quot;,
"vue.rearranger.settings.migration": "true" &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
} }
}]]></component> }</component>
<component name="RecentsManager"> <component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS"> <key name="MoveFile.RECENT_KEYS">
<recent name="E:\Code\python\iOSAI\resources" /> <recent name="E:\Code\python\iOSAI\resources" />
@@ -163,7 +165,8 @@
<workItem from="1756101135190" duration="18679000" /> <workItem from="1756101135190" duration="18679000" />
<workItem from="1756124879602" duration="580000" /> <workItem from="1756124879602" duration="580000" />
<workItem from="1756184656258" duration="24292000" /> <workItem from="1756184656258" duration="24292000" />
<workItem from="1756271781908" duration="26153000" /> <workItem from="1756271781908" duration="27411000" />
<workItem from="1756357505672" duration="11939000" />
</task> </task>
<task id="LOCAL-00001" summary="ai 开始测试"> <task id="LOCAL-00001" summary="ai 开始测试">
<option name="closed" value="true" /> <option name="closed" value="true" />
@@ -173,7 +176,15 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1756303135240</updated> <updated>1756303135240</updated>
</task> </task>
<option name="localTasksCounter" value="2" /> <task id="LOCAL-00002" summary="ai 开始测试">
<option name="closed" value="true" />
<created>1756303233850</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1756303233850</updated>
</task>
<option name="localTasksCounter" value="3" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@@ -187,7 +198,7 @@
<option name="LAST_COMMIT_MESSAGE" value="ai 开始测试" /> <option name="LAST_COMMIT_MESSAGE" value="ai 开始测试" />
</component> </component>
<component name="com.intellij.coverage.CoverageDataManagerImpl"> <component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/iOSAI$Main.coverage" NAME="Main 覆盖结果" MODIFIED="1756302588713" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" /> <SUITE FILE_PATH="coverage/iOSAI$Main.coverage" NAME="Main 覆盖结果" MODIFIED="1756368721406" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
<SUITE FILE_PATH="coverage/iOSAI$123.coverage" NAME="123 覆盖结果" MODIFIED="1756300694280" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" /> <SUITE FILE_PATH="coverage/iOSAI$123.coverage" NAME="123 覆盖结果" MODIFIED="1756365089648" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test" />
</component> </component>
</project> </project>

View File

@@ -81,11 +81,11 @@ class ControlUtils(object):
x, y = AiUtils.findImageInScreen("add", udid) x, y = AiUtils.findImageInScreen("add", udid)
print(x, y) print(x, y)
if x > -1: if x > -1:
print("点赞了") LogManager.info("点赞了",udid)
session.click(x // scale, y // scale + 50) session.click(x // scale, y // scale + 50)
return True return True
else: else:
print("没有找到目标") LogManager.info("没有找到目标",udid)
return False return False
# 点击搜索 # 点击搜索

Binary file not shown.

Before

Width:  |  Height:  |  Size: 769 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 MiB

View File

@@ -49,7 +49,7 @@ class ScriptManager():
time.sleep(1) time.sleep(1)
ControlUtils.openTikTok(session, udid) ControlUtils.openTikTok(session, udid)
time.sleep(3) time.sleep(3)
LogManager.info("养号重启tiktok")
AiUtils.makeUdidDir(udid) AiUtils.makeUdidDir(udid)
# ========= 主循环 ========= # ========= 主循环 =========
@@ -59,7 +59,15 @@ class ScriptManager():
session.appium_settings({"snapshotMaxDepth": 15}) session.appium_settings({"snapshotMaxDepth": 15})
# 判断当前页面上是否有推荐按钮 # 判断当前页面上是否有推荐按钮
el = session(xpath='//XCUIElementTypeButton[@name="top_tabs_recomend"]') # el = session(xpath='//XCUIElementTypeButton[@name="top_tabs_recomend"]')
# node = session.xpath(
# '//XCUIElementTypeButton[@name="top_tabs_recomend" or @name="推荐" or @label="推荐"]'
# )
el = session.xpath(
'//XCUIElementTypeButton[@name="top_tabs_recomend" or @name="推荐" or @label="推荐"]'
)
if not el.exists: if not el.exists:
# 记录日志 # 记录日志
LogManager.error("找不到推荐按钮,养号出现问题,重启养号功能", udid=udid) LogManager.error("找不到推荐按钮,养号出现问题,重启养号功能", udid=udid)
@@ -70,6 +78,7 @@ class ScriptManager():
LogManager.error("当前页面不是推荐页面,养号出现问题,重启养号功能", udid=udid) LogManager.error("当前页面不是推荐页面,养号出现问题,重启养号功能", udid=udid)
raise Exception("当前页面不是推荐页面,养号出现问题,重启养号功能") raise Exception("当前页面不是推荐页面,养号出现问题,重启养号功能")
LogManager.info("当前页面是推荐页面,开始养号")
# 重新设置节点的深度,防止手机进行卡顿 # 重新设置节点的深度,防止手机进行卡顿
session.appium_settings({"snapshotMaxDepth": 0}) session.appium_settings({"snapshotMaxDepth": 0})
@@ -105,7 +114,7 @@ class ScriptManager():
needLike = random.randint(0, 100) needLike = random.randint(0, 100)
homeButton = AiUtils.findHomeButton(udid) homeButton = AiUtils.findHomeButton(udid)
if homeButton: if homeButton:
print("有首页按钮,查看视频") LogManager.info("有首页按钮,查看视频", udid)
videoTime = random.randint(5, 15) videoTime = random.randint(5, 15)
time.sleep(videoTime) time.sleep(videoTime)
@@ -115,16 +124,16 @@ class ScriptManager():
session.appium_settings({"snapshotMaxDepth": 0}) session.appium_settings({"snapshotMaxDepth": 0})
if needLike < 3: if needLike < 3:
print("点赞") LogManager.info("进行点赞", udid)
ControlUtils.clickLike(session, udid) ControlUtils.clickLike(session, udid)
print("继续观看视频") LogManager.info("继续观看视频", udid)
videoTime = random.randint(10, 30) videoTime = random.randint(10, 30)
time.sleep(videoTime) time.sleep(videoTime)
print("准备划到下一个视频") LogManager.info("准备划到下一个视频", udid)
client.swipe_up() client.swipe_up()
else: else:
print("找不到首页按钮。出错了") LogManager.error("找不到首页按钮。出错了", udid)
else: else:
nextTime = random.randint(1, 5) nextTime = random.randint(1, 5)
time.sleep(nextTime) time.sleep(nextTime)
@@ -135,8 +144,7 @@ class ScriptManager():
raise e # 抛出给上层,触发重生机制 raise e # 抛出给上层,触发重生机制
except Exception as e: except Exception as e:
LogManager.error(f"养号出现异常: {e}", udid) LogManager.error(f"[{udid}] 养号出现异常,将重启流程: {e}", udid)
print(f"[{udid}] 养号出现异常,将重启流程: {e}")
retries += 1 retries += 1
time.sleep(3) # 等待后重生 time.sleep(3) # 等待后重生
@@ -171,6 +179,14 @@ class ScriptManager():
raise Exception(f"找不到直播按钮,抛出异常 重新启动") raise Exception(f"找不到直播按钮,抛出异常 重新启动")
time.sleep(20) time.sleep(20)
live_button = session(xpath='//XCUIElementTypeButton[@name="直播"]')
if live_button.exists:
continue
# 下滑一下
client.swipe_up()
# 3) 取分辨率;可选重建 session 规避句柄陈旧 # 3) 取分辨率;可选重建 session 规避句柄陈旧
size = session.window_size() size = session.window_size()
width, height = size.width, size.height width, height = size.width, size.height
@@ -182,10 +198,15 @@ class ScriptManager():
# 找到一个看直播的时候肯定有的元素,当这个元素没有的时候,就代表当前的页面出现了问题 # 找到一个看直播的时候肯定有的元素,当这个元素没有的时候,就代表当前的页面出现了问题
# 需要抛出异常,重启这个流程 # 需要抛出异常,重启这个流程
el1 = session.xpath('//XCUIElementTypeOther[@name="GBLFeedRootViewComponent"]')
el2 = session.xpath('//XCUIElementTypeOther[@value="0%"]')
if not session(xpath="//XCUIElementTypeOther[@name='RoomContainer' and @visible='true']").exists: if not (el1.exists or el2.exists):
print("当前页面不是直播间,重启刷直播")
LogManager.error("当前页面不是直播间,重启刷直播", udid=udid) LogManager.error("当前页面不是直播间,重启刷直播", udid=udid)
raise Exception("当前页面不是直播间") raise Exception("当前页面不是直播间")
else:
print("当前页面是直播间,继续刷直播")
# PK 直接划走 # PK 直接划走
if session(xpath='//XCUIElementTypeOther[@name="kGBLInteractionViewMatchScoreBar"]').exists: if session(xpath='//XCUIElementTypeOther[@name="kGBLInteractionViewMatchScoreBar"]').exists:
@@ -205,7 +226,7 @@ class ScriptManager():
print("✅ 单窗口,(10%概率)开始点赞") print("✅ 单窗口,(10%概率)开始点赞")
# 随机点赞(仍保留中途保护) # 随机点赞(仍保留中途保护)
if random.random() >= 0.90: if random.random() >= 0.97:
print("开始点赞") print("开始点赞")
for _ in range(random.randint(10, 30)): for _ in range(random.randint(10, 30)):
# 中途转PK/连麦立即跳过 # 中途转PK/连麦立即跳过