惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
雷峰网
雷峰网
S
SegmentFault 最新的问题
量子位
有赞技术团队
有赞技术团队
V
V2EX
宝玉的分享
宝玉的分享
Hugging Face - Blog
Hugging Face - Blog
B
Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Jina AI
Jina AI
C
Check Point Blog
G
Google Developers Blog
博客园 - 叶小钗
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园_首页
T
Tailwind CSS Blog
B
Blog RSS Feed
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
酷 壳 – CoolShell
酷 壳 – CoolShell
U
Unit 42

博客园 - papering

telnet 由于系统缓冲区空间不足或队列已满,不能执行套接字上的操作 string byte 内存 硬盘 CAS ABA AtomicLong mysql 索引长度限制 docker network FTP Connection Modes (Active vs. Passive) 字符长度 mysql 【车载架构】AUTOSAR CP系列之27:系统内核之 WdgM 看门狗管理 单目录文件数限制 在联表 join 时 使用 case when 按不同的条件关联不同的行 JDK21 Process Reaper TLS 栈溢出循环故障深度分析 栈溢出 写入相邻的内存区域 GCC 的 -fstack-protector 会在每个函数的栈帧底部放一个随机“金丝雀值”,函数返回前检查它是否被改掉,以此检测栈缓冲区溢出。 潜伏5年!GitLab高危RCE漏洞爆发,低权限即可控服 Redis 漏洞分析——lua 脚本篇 Redis guarantees the script's atomic execution. AMQP 0-9-1 连接通过 信道 进行多路复用,信道可以被认为是“共享单一 TCP 连接的轻量级连接”。 WSAETIMEDOUT WSAEACCES This module supports asynchronous I/O on multiple file descriptors. 设置其优先级值的线程的句柄 QT 主线程 优化 卡顿 主线程上的同步重活 防重入:进行中直接 return,避免连点双开。 把「一次性任务」收到 ThreadPoolExecutor(max_workers=2~3),限制峰值线程数 统一 Activity 浮层 去掉连环成功弹窗 为 with语句上下文提供的工具 懒加载 IDE发现 import Canvas 指纹 魔改chromium源码——CDP(Chrome DevTools Protocol)检测01 whether the browser environment is controlled by a robot. chromium指纹魔改 对拷线 rpa 任务编排 a JSON formatted stream to ``fp`` “幽灵字符”问题
CDP 键盘操作 操作清单
papering · 2026-09-20 · via 博客园 - papering

input package - github.com/chromedp/cdproto/input - Go Packages

协议监控:查看和发送 CDP 请求  |  Chrome DevTools  |  Chrome for Developers

对浏览器cdp协议中 Runtime.evaluate Input.dispatchKeyEvent DOM.setFileInputFiles 等五个命令的作用说明和联系组合 - Quicker

1.Runtime.evaluate(运行js代码)
2.Input.dispatchKeyEvent(键盘按键)
3.Input.insertText(键盘文字输入)
4.Input.dispatchMouseEvent(鼠标点击)
5.DOM.setFileInputFiles(上传文件)
说明一下它们其中的之间的联系和作用

(1)Runtime.evaluate(运行js代码) 
它的作用是运作js代码字符串和获取返回值。和其他命令组合起来就可以实现很多事件
如:
chrome.debugger.sendCommand(n, "Runtime.evaluate", {expression: 'document.querySelector("#text-editor").focus()'});

(2)Input.dispatchKeyEvent(键盘按键)  和  Runtime.evaluate(运行js代码)  组合一起的作用
使用js代码设置焦点再和键盘按键组合起来
可以解决按钮使用js代码点击无效的情况
可以模拟全选,复制,粘贴,切换,焦点
如:
chrome.debugger.sendCommand(n, "Runtime.evaluate", {expression: 'document.querySelector("#fileLabel").focus()'},a=>chrome.debugger.sendCommand(n,"Input.dispatchKeyEvent",{ key: "Enter", text: "\r",type: "keyDown" }));

(3)Input.insertText(键盘文字输入)  和  Runtime.evaluate(运行js代码)  组合一起的作用
使用js代码设置焦点再和键盘文字输入组合起来
可以解决文本框,富文本框,自定义文本框使用js代码输入无效的情况
如:
chrome.debugger.sendCommand(n, "Runtime.evaluate", {expression: 'document.querySelector("#text-editor").focus()'});
chrome.debugger.sendCommand( n,"Input.insertText",{text: "Hello, World!"});

(4)Input.dispatchMouseEvent(鼠标点击)  和  Runtime.evaluate(运行js代码)  组合一起的作用
使用js代码获取按钮坐标再和鼠标点击组合起来
可以解决按钮使用js代码点击无效的情况(键盘按键可以达到一样的效果)
如:
chrome.debugger.sendCommand(n, "Runtime.evaluate", {expression: 'var rect = document.querySelector(".submit-btn").getBoundingClientRect();var x = rect.left + rect.width / 2;var y = rect.top + rect.height / 2; [x,y]',returnByValue:true} ,   a=>{let [x,y]=a.result.value;
chrome.debugger.sendCommand(n, "Input.dispatchMouseEvent",{type: "mousePressed", x: x,y: y,button: "left",clickCount: 1});
chrome.debugger.sendCommand(n, "Input.dispatchMouseEvent",{type: "mouseReleased", x: x,y: y,button: "left",clickCount: 1});
});

(5)DOM.setFileInputFiles(上传文件)  和  Runtime.evaluate(运行js代码)  组合一起的作用
使用js代码获取文件上传框的objectId再上传文件命令组合起来
可以解决自动上传文件和跨框架上传文件
如:
chrome.debugger.sendCommand(n, "Runtime.evaluate", {expression: "document.querySelector('#fileInput')"},a=>chrome.debugger.sendCommand(n, "DOM.setFileInputFiles", { objectId: a.result.objectId, files: ["C:/Users/Administrator/Desktop/11.png"]}));