临时提交
This commit is contained in:
@@ -196,24 +196,34 @@ class ScriptManager():
|
||||
session.appium_settings({"snapshotMaxDepth": 15})
|
||||
# 点击搜索按钮
|
||||
ControlUtils.clickSearch(session)
|
||||
# 查找输入框
|
||||
input = session.xpath('//XCUIElementTypeSearchField')
|
||||
# 如果找到了输入框,就点击并且输入内容
|
||||
input.click()
|
||||
# 稍作停顿
|
||||
time.sleep(1)
|
||||
|
||||
# 返回上一步
|
||||
def goBack():
|
||||
# ControlUtils.clickBack(session)
|
||||
client.swipe(5,120, 50, 120)
|
||||
|
||||
# 删除数据
|
||||
removeModelFromAnchorList(anchor)
|
||||
|
||||
def goBack(count):
|
||||
# 如需回复消息
|
||||
if needReply:
|
||||
count += 1
|
||||
for i in range(count):
|
||||
ControlUtils.clickBack(session)
|
||||
time.sleep(2)
|
||||
|
||||
# 循环条件。1、 循环关闭 2、 数据处理完毕
|
||||
while not event.is_set() or len(anchorList) > 0:
|
||||
if needReply:
|
||||
print("如果需要回复主播消息。走此逻辑")
|
||||
if AiUtils.getUnReadMsgCount(session) > 0:
|
||||
# 此处调用另外一个方法处理
|
||||
|
||||
# 设置查找深度
|
||||
session.appium_settings({"snapshotMaxDepth": 15})
|
||||
# 点击搜索按钮
|
||||
ControlUtils.clickSearch(session)
|
||||
|
||||
# 查找输入框
|
||||
input = session.xpath('//XCUIElementTypeSearchField')
|
||||
# 如果找到了输入框,就点击并且输入内容
|
||||
input.click()
|
||||
# 稍作停顿
|
||||
time.sleep(1)
|
||||
|
||||
# 获取一个主播
|
||||
anchor = anchorList[0]
|
||||
@@ -229,16 +239,18 @@ class ScriptManager():
|
||||
session.appium_settings({"snapshotMaxDepth": 25})
|
||||
|
||||
# 定位 "关注" 按钮 通过关注按钮的位置点击主播首页
|
||||
follow_button = session.xpath(
|
||||
'//XCUIElementTypeCell[@index="1"]//XCUIElementTypeButton[@index="1"]').get()
|
||||
if follow_button:
|
||||
follow_button = session.xpath('//XCUIElementTypeOther[@name="zhang1231511"]//XCUIElementTypeButton[@enabled="true" and @visible="true"]')
|
||||
time.sleep(2)
|
||||
if follow_button.exists:
|
||||
print("找到关注按钮!")
|
||||
x = follow_button.bounds.x - 200
|
||||
y = follow_button.bounds.y
|
||||
client.click(x, y)
|
||||
else:
|
||||
goBack(1)
|
||||
removeModelFromAnchorList(anchor)
|
||||
print("未找到关注按钮")
|
||||
|
||||
continue
|
||||
time.sleep(3)
|
||||
|
||||
# 找到并点击第一个视频
|
||||
@@ -248,7 +260,8 @@ class ScriptManager():
|
||||
def viewAnchorVideo():
|
||||
print("开始查看视频")
|
||||
count = 2
|
||||
while count > 0:
|
||||
while count != 0:
|
||||
time.sleep(5)
|
||||
print("条件满足,继续查看")
|
||||
img = client.screenshot()
|
||||
time.sleep(1)
|
||||
@@ -256,44 +269,49 @@ class ScriptManager():
|
||||
img.save(filePath)
|
||||
LogManager.info("保存屏幕图像成功", udid)
|
||||
print("保存了背景图")
|
||||
time.sleep(1)
|
||||
time.sleep(2)
|
||||
# 查找add图标
|
||||
addX, addY = AiUtils.findImageInScreen("add", udid)
|
||||
if addX != -1:
|
||||
r = ControlUtils.clickLike(session, udid)
|
||||
# 如果点了赞,总数量-1 否则划下一个视频,无法点赞的原因很多。指不定是什么原因。所以直接下一个视频比较好
|
||||
if r:
|
||||
# 点赞成功。总数量减1,否则就滑到下一个视频。原因太多。不好判断。不如直接下一个视频
|
||||
if r == True:
|
||||
count -= 1
|
||||
else:
|
||||
client.swipe_up()
|
||||
else:
|
||||
print("没找有效视频")
|
||||
client.swipe_up()
|
||||
continue
|
||||
|
||||
# 假装看几秒视频
|
||||
time.sleep(10)
|
||||
client.swipe_up()
|
||||
if count == 1:
|
||||
client.swipe_right()
|
||||
break
|
||||
|
||||
# 点击第一个视频后的逻辑
|
||||
if cellClickResult:
|
||||
# 假装看几秒视频
|
||||
time.sleep(5)
|
||||
client.swipe_up()
|
||||
|
||||
if count == 0:
|
||||
ControlUtils.clickBack(session)
|
||||
break
|
||||
|
||||
# 如果打开视频失败。说明该主播没有视频
|
||||
if cellClickResult == True:
|
||||
print("点击了视频")
|
||||
session.appium_settings({"snapshotMaxDepth": 5})
|
||||
session.appium_settings({"snapshotMaxDepth": 15})
|
||||
time.sleep(2)
|
||||
print("重新设置了匹配深度")
|
||||
viewAnchorVideo()
|
||||
time.sleep(2)
|
||||
print("视频看完了")
|
||||
session.appium_settings({"snapshotMaxDepth": 25})
|
||||
# 视频看完需要点关注。
|
||||
r = ControlUtils.clickFollowButton(session)
|
||||
if r == False:
|
||||
print("执行失败了")
|
||||
|
||||
|
||||
# 点击关注按钮
|
||||
followButton = AiUtils.getFollowButton(session)
|
||||
if followButton.exists:
|
||||
followButton.click()
|
||||
else:
|
||||
goBack(2)
|
||||
return
|
||||
|
||||
time.sleep(2)
|
||||
ControlUtils.clickFollowButton(session)
|
||||
AiUtils.getSendMesageButton(session)
|
||||
time.sleep(2)
|
||||
|
||||
# 查找聊天界面中的输入框节点
|
||||
@@ -303,40 +321,31 @@ class ScriptManager():
|
||||
# 准备发送一条信息
|
||||
chatInput.click()
|
||||
time.sleep(2)
|
||||
# text = random.choice(prologueList)
|
||||
# msg = Requester.translation(text, anchorCountry)
|
||||
chatInput.set_text("哈哈哈" + "\n")
|
||||
text = random.choice(prologueList)
|
||||
msg = Requester.translation(text, anchorCountry)
|
||||
chatInput.set_text(msg + "\n")
|
||||
time.sleep(1)
|
||||
|
||||
client.swipe_right()
|
||||
time.sleep(1)
|
||||
client.swipe_right()
|
||||
time.sleep(2)
|
||||
else:
|
||||
print("没找到")
|
||||
client.swipe_right()
|
||||
time.sleep(1)
|
||||
client.swipe_right()
|
||||
time.sleep(2)
|
||||
break
|
||||
print("无法发送信息,换个主播")
|
||||
# 接着下一个主播
|
||||
goBack(3)
|
||||
|
||||
# 清除数据
|
||||
removeModelFromAnchorList(anchor)
|
||||
# 流程结束
|
||||
# client.swipe_right()
|
||||
# time.sleep(1)
|
||||
else:
|
||||
print("获取该主播第一个视频失败")
|
||||
goBack()
|
||||
print("没找到主播的第一个视频")
|
||||
# 删除当前数据
|
||||
removeModelFromAnchorList(anchor)
|
||||
goBack(2)
|
||||
|
||||
|
||||
|
||||
def test(self, udid):
|
||||
client = wda.USBClient(udid)
|
||||
client.swipe_right()
|
||||
session = client.session()
|
||||
session.appium_settings({"snapshotMaxDepth": 10})
|
||||
|
||||
print(client.source())
|
||||
|
||||
manager = ScriptManager()
|
||||
manager.test("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")
|
||||
# manager = ScriptManager()
|
||||
# manager.test("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")
|
||||
# manager.growAccount("eca000fcb6f55d7ed9b4c524055214c26a7de7aa")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user