feat: 步骤新增剪贴板注入(可注入+粘贴,批量发链接场景)+ adb终端快捷命令 tcpip 5555 转网络调试

This commit is contained in:
2026-08-15 15:53:31 +08:00
parent 17f849f723
commit a51857d143
3 changed files with 34 additions and 0 deletions
+24
View File
@@ -69,6 +69,8 @@ STEP_TYPES = [
"params": {"selector_type": "xpath", "selector_value": "", "timeout": 10}},
{"type": "input_text", "label": "输入文字", "icon": "⌨",
"params": {"mode": "random", "texts": "你好\n有趣\n支持", "fixed_text": "", "clear_first": True}},
{"type": "clipboard", "label": "剪贴板注入", "icon": "📋",
"params": {"text": "", "paste": True}},
{"type": "wait", "label": "等待", "icon": "⏱",
"params": {"min": 1.0, "max": 3.0}},
{"type": "loop", "label": "循环块", "icon": "↻",
@@ -475,6 +477,28 @@ class GenericStepsWorker(BaseWorker):
_log.warning(f"[{self.serial}] click 异常: {e}")
return found # 命中结果,"测试此步骤"用
def _exec_clipboard(self, d, params, depth=0):
"""剪贴板注入:写入指定内容到剪贴板,可选立即粘贴到当前聚焦的输入框。
批量发链接场景:先聚焦评论区输入框 → 注入+粘贴链接1 → 换链接 → 注入+粘贴链接2……
粘贴模式复用 u2 send_keys(内部 setClipboard + pasteClipboard,与"输入文字"同机制)。
"""
text = str(params.get("text", "") or "")
if not text:
_log.warning(f"[{self.serial}] clipboard 内容为空,跳过")
return False
try:
if params.get("paste"):
d.send_keys(text) # setClipboard + pasteClipboard
_log.info(f"[{self.serial}] 剪贴板注入并粘贴: {text[:60]}")
else:
d.set_clipboard(text)
_log.info(f"[{self.serial}] 剪贴板注入(不粘贴): {text[:60]}")
return True
except Exception as e:
_log.warning(f"[{self.serial}] 剪贴板注入异常: {e}")
return False
def _exec_wait(self, d, params, depth=0):
min_s = float(params.get("min", 1.0))
max_s = float(params.get("max", 3.0))