feat(流水线): 资产管理 + 计划编排 + 运行监测 + 切号/发布修复
- 流水线收口为四栏:资产管理 / 动作 / 计划调度 / 运行监测 - 资产管理:账号总表与设备筛选、素材 13 列、模板批量导入(数量+文件名校验)、 单条上传、删除账号(归档不删原件)、发布记录 - 计划调度:segments 多动作组/任务编排(发布素材/循环/条件/回主页)、 内置切号可见可编辑、每账号切号前亮屏 - 运行监测:计划/账号/设备三维度、按需截图、按账号拆分显示 - 修复:图片相册索引误报、切号重试与重复点「我」、发布任务校验跳过、 多号同机假账号目录、编辑器 expect_el 未声明变量 - 文档与测试同步(14/14)
This commit is contained in:
@@ -71,13 +71,23 @@ class El:
|
||||
class StubD:
|
||||
"""模拟抖音:能读昵称、能进账号列表、能按名字点号。"""
|
||||
|
||||
def __init__(self, cur='小李', accounts=('小王', '小李'), login=False):
|
||||
def __init__(self, cur='小李', accounts=('小王', '小李'), login=False,
|
||||
home_only=False):
|
||||
self.cur = cur
|
||||
self.accounts = list(accounts)
|
||||
self.login = login
|
||||
self.clicked = []
|
||||
self.switch_ok = True # False = 点了但没切过去(模拟没生效)
|
||||
self.switch_open = True # False = 进不去账号列表
|
||||
# home_only=True 模拟真机:**昵称控件只在「我」页存在**,不先点「我」就读不到名字
|
||||
self.home_only = home_only
|
||||
self.on_me = False
|
||||
self.me_clicks = 0
|
||||
self.backs = 0
|
||||
|
||||
def press(self, key):
|
||||
if key == 'back':
|
||||
self.backs += 1
|
||||
|
||||
def _click_name(self, name):
|
||||
self.clicked.append(name)
|
||||
@@ -88,18 +98,32 @@ class StubD:
|
||||
|
||||
LOGIN_HINTS = ('验证码', '其他方式登录', '手机号登录', '一键登录', '密码登录')
|
||||
|
||||
ME_TAB = '//*[@resource-id="com.ss.android.ugc.aweme:id/0py" and @text="我"]'
|
||||
|
||||
def xpath(self, v):
|
||||
if v == self.ME_TAB:
|
||||
# 底部「我」页签(真实抖音上就是这条 xpath —— 精确,不会撞上带「我」的音乐条)
|
||||
self.on_me = True
|
||||
self.me_clicks += 1
|
||||
return El('我')
|
||||
if v == '//name':
|
||||
# 登录页上**根本没有昵称这个控件**(元素不存在)—— 这才是真实情况,
|
||||
# 所以"读名字"会读到空串(而不是读到一堆登录页的文字)
|
||||
return El(None, exists=False) if self.login else El(self.cur)
|
||||
if self.login:
|
||||
return El(None, exists=False)
|
||||
if self.home_only and not self.on_me:
|
||||
return El(None, exists=False) # 没在「我」页 → 读不到
|
||||
return El(self.cur)
|
||||
if v == '//switch':
|
||||
return El('', exists=(self.switch_open and not self.login))
|
||||
return El('', exists=False)
|
||||
|
||||
def __call__(self, **kw):
|
||||
if 'descriptionContains' in kw:
|
||||
return El('', exists=(kw['descriptionContains'] == '我'))
|
||||
if kw['descriptionContains'] == '我':
|
||||
self.on_me = True # 点底部「我」= 到了个人页(昵称这才读得到)
|
||||
return El('')
|
||||
return El('', exists=False)
|
||||
if 'textContains' in kw:
|
||||
nm = kw['textContains']
|
||||
if self.login and nm in self.LOGIN_HINTS:
|
||||
@@ -132,6 +156,34 @@ try:
|
||||
check('返回 True', w._exec_switch_account(d, PARAMS), True)
|
||||
check('一个号都没点', d.clicked, [])
|
||||
|
||||
print('=== 1b. 停在首页(昵称读不到)+ 当前就是目标 → 先点「我」读一次,一下都不切 ===')
|
||||
w = gt.GenericStepsWorker("F1b", {})
|
||||
w._vars['target_name'] = '小李'
|
||||
d = StubD(cur='小李', home_only=True) # 不点「我」就读不到名字 → 必须先去「我」页
|
||||
check('返回 True(认出来了)', w._exec_switch_account(d, PARAMS), True)
|
||||
check('为了读名字点了「我」页签', d.on_me, True)
|
||||
check('一个号都没点(压根没进账号列表)', d.clicked, [])
|
||||
from core import device_worker as _dw
|
||||
_act = [x for x in _dw.get_all_worker_status() if x.get('serial') == 'F1b']
|
||||
check('步骤说明写明"不用切"', '不用切' in ((_act[0].get('current_action') or '') if _act else ''), True)
|
||||
|
||||
print('=== 1c. 停在首页(昵称读不到)+ 不是目标 → 读一眼后照常切 ===')
|
||||
w = gt.GenericStepsWorker("F1c", {})
|
||||
w._vars['target_name'] = '小王'
|
||||
d = StubD(cur='小李', home_only=True)
|
||||
check('返回 True', w._exec_switch_account(d, PARAMS), True)
|
||||
check('点了目标那个号(只点它一下)', d.clicked, ['小王'])
|
||||
|
||||
print('=== 1d. 没配 me_selector 时的默认值 = **精确页签 xpath**(不撞「拍同款」)===')
|
||||
w = gt.GenericStepsWorker("F1d", {})
|
||||
w._vars['target_name'] = '小王'
|
||||
mt, mv = w._me_selector({})
|
||||
check('默认是 xpath(不是 descriptionContains=我)', mt, 'xpath')
|
||||
check('默认精确到 id + text', mv, StubD.ME_TAB)
|
||||
check('步骤里配了就听步骤的',
|
||||
w._me_selector({'me_selector_type': 'descriptionContains', 'me_selector_value': '我的'}),
|
||||
('descriptionContains', '我的'))
|
||||
|
||||
print('=== 2. 切到另一个号(在列表里按名字点)===')
|
||||
w = gt.GenericStepsWorker("F2", {})
|
||||
w._vars['target_name'] = '小王'
|
||||
@@ -140,17 +192,49 @@ try:
|
||||
check('点是按名字点的', d.clicked, ['小王'])
|
||||
check('当前号变了', d.cur, '小王')
|
||||
check('顺手把运行期变量同步成新名字', w._vars.get('account_name'), '小王')
|
||||
check('切号前只点了一次「我」(不重复点当前页签 → 不会下拉刷新)',
|
||||
d.me_clicks, 1)
|
||||
|
||||
print('=== 3. 列表里没有这个名字(本机没登)→ 立刻 False、不重试 ===')
|
||||
print('=== 3. 列表里确实没有这个名字 → 重试一次后 False ===')
|
||||
notes.clear()
|
||||
w = gt.GenericStepsWorker("F3", {})
|
||||
w._vars['target_name'] = '不存在的号'
|
||||
d = StubD(cur='小李')
|
||||
check('返回 False', w._exec_switch_account(d, PARAMS), False)
|
||||
check('只找了一次(没重试)', d.clicked, [])
|
||||
check('没点到任何号', d.clicked, [])
|
||||
check('两次都没找到 → 关过一次列表重试', d.backs, 1)
|
||||
check('发了切号失败通知', [n[0] for n in notes], ['task.account.switch_failed'])
|
||||
check('通知里带上想切的目标', notes[0][1], '不存在的号')
|
||||
|
||||
print('=== 3b. 第一次列表没加载出来、第二次有了 → 重试后能切成 ===')
|
||||
notes.clear()
|
||||
|
||||
class FlakyD(StubD):
|
||||
"""模拟冷启动后列表还没拉完:第一次打开只看得到别的号,第二次才出现目标。"""
|
||||
def __init__(self, *a, **kw):
|
||||
super().__init__(*a, **kw)
|
||||
self.opens = 0
|
||||
|
||||
def xpath(self, v):
|
||||
if v == '//switch':
|
||||
self.opens += 1
|
||||
return El('', exists=True)
|
||||
return super().xpath(v)
|
||||
|
||||
def __call__(self, **kw):
|
||||
if (kw.get('textContains') == '小王' or kw.get('descriptionContains') == '小王'
|
||||
or kw.get('text') == '小王'):
|
||||
if self.opens < 2:
|
||||
return El('', exists=False)
|
||||
return super().__call__(**kw)
|
||||
|
||||
w = gt.GenericStepsWorker("F3b", {})
|
||||
w._vars['target_name'] = '小王'
|
||||
d = FlakyD(cur='小李')
|
||||
check('重试后成功', w._exec_switch_account(d, PARAMS), True)
|
||||
check('点到了目标号', d.clicked, ['小王'])
|
||||
check('当前号变了', d.cur, '小王')
|
||||
|
||||
print('=== 4. 点了但没切过去 → 按 max_attempts 重试后放弃 + 通知 ===')
|
||||
notes.clear()
|
||||
w = gt.GenericStepsWorker("F4", {})
|
||||
|
||||
Reference in New Issue
Block a user