scripts_setFileInputFiles,想问下这个命令,适用哪些场景的?

使用问题 · 136 次浏览
反卷练习生 创建于 24天4小时前

scripts_setFileInputFiles,想问下这个命令,适用哪些场景的?下面这种能实现吗?


回复内容
反卷练习生 回复 CL 23天20小时前 :
Win-10.0.22635.0 Quicker-1.44.19.0 动作ID:a7678790-b4be-43e3-bf70-5368c39c9bc4 来源动作: v0
Log文件路径:C:\Users\Administrator\AppData\Local\Temp\quicker_测试13_070547-242_log.html 定位文件 复制文件 上传并复制网址
开始执行动作:测试13 2025-06-23 19:05:47
0动作初始化
00浏览器控制浏览器:运行后台命令 (MV3版扩展)
[in]失败后停止【值/表达式】True
[in]操作类型【值/表达式】BackgroundCommand
[in]超时时间(ms)【值/表达式】3000
[in]标签页Id【无输入】
连接的浏览器:chrome
[in]命令【值/表达式】scripts_setFileInputFiles
[in]命令参数【值/表达式】{ "selector": "input[@id='html5_1iue6ti2217is1dpot3p2dua7i3']", "files": ["D:/Administrator/Downloads/IMG_20250623_160654.jpg"] }
[in]返回值过滤器【值/表达式】
[in]等待操作完成或返回数据【值/表达式】True
异常:后台脚本返回失败!{"code":-32000,"message":"DOM Error while querying"}{}
在 tfanttUAA5nOWlnYTigs.ucsyXIyzzuC6GpVWbEgX.PN2UAmEkyc5(ActionStep , ActionExecuteContext , XAction , Int32 ) 在 tfanttUAA5nOWlnYTigs.ucsyXIyzzuC6GpVWbEgX.<>c__DisplayClass104_0.LmhZjKv8m69()
检测到了中止标志(OperationFailed),停止后续步骤执行。
动作结束。耗时:164.5266ms 我测试了好久,后面提示这个错误,啥原因呢
CL 最后更新于 22天4小时前
反卷练习生 回复 CL 23天20小时前 :
浏览器控制浏览器:运行后台命令 (MV3版扩展)
[in]失败后停止【值/表达式】True
[in]操作类型【值/表达式】BackgroundCommand
[in]超时时间(ms)【值/表达式】3000
[in]标签页Id【无输入】
连接的浏览器:chrome
[in]命令【值/表达式】scripts_setFileInputFiles
[in]命令参数【值/表达式】{ "target": {"tabId": 757707816}, "selector": "input[type='file']", "files": ["D:/Administrator/Downloads/IMG_20250623_160654.jpg"] }
[in]返回值过滤器【值/表达式】
[in]等待操作完成或返回数据【值/表达式】True
异常:后台脚本返回失败!Debugger is not attached to the tab with id: 757707816.{}
在 tfanttUAA5nOWlnYTigs.ucsyXIyzzuC6GpVWbEgX.PN2UAmEkyc5(ActionStep , ActionExecuteContext , XAction , Int32 ) 在 tfanttUAA5nOWlnYTigs.ucsyXIyzzuC6GpVWbEgX.<>c__DisplayClass104_0.LmhZjKv8m69() 在 Quicker.Domain.Actions.X.XActionHelper.ExecuteCommonAction(ActionExecuteContext context, ActionStep step, X
步骤(sys:chromecontrol)执行失败,原因:后台脚本返回失败!Debugger is not attached to the tab with id: 757707816.{}
停止动作:后台脚本返回失败!Debugger is not attached to the tab with id: 757707816.{}
CL 最后更新于 22天4小时前
CL 回复 反卷练习生 23天17小时前 :

不太清楚。 开发者模式开启了么?

反卷练习生 回复 CL 23天2小时前 :

是开启的

反卷练习生 回复 CL 23天1小时前 :


测试了quicker官网是支持的,淘宝商家后台好像不支持,后面再测试下

反卷练习生 回复 CL 22天22小时前 :

是不是和那个“等待网页变化功能”一样,也是框架的问题,能不能修复下;使用获取元素信息没问题。

反卷练习生 回复 反卷练习生 22天22小时前 :

刚刚测试了,确实和“等待网页变化”一样

CL 回复 反卷练习生 22天6小时前 :

框架让这个问题变得比较复杂,目前的API无法比较简单的获取和指定框架id。

反卷练习生 回复 CL 22天5小时前 :

那这个问题能修复吗

CL 回复 反卷练习生 22天4小时前 :

目前没有什么思路

涛涛涛 回复 CL 9天18小时前 :

关于跨框架上传文件的方式:再加一个框架的css就可以了

async function 上传文件1(e) {
            let { tabId: t, iframeselector: r, fileInputselector: o, files:g } = e
            var n={tabId: t}
            let a= await chrome.debugger.attach(n, "1.3");
            let l = await chrome.debugger.sendCommand(n, "DOM.getDocument", {});
            l = await chrome.debugger.sendCommand(n,"DOM.querySelector", {"nodeId": l.root.nodeId,"selector":r});
            l = await chrome.debugger.sendCommand(n,"DOM.querySelector", {"nodeId": l.nodeId+1,"selector":o});
            l = await chrome.debugger.sendCommand(n, "DOM.setFileInputFiles", {"nodeId":l.nodeId,"files":g});
            console.log("测试1");
}

//参数说明
tabId:  调试目标
iframeselector:  iframe框架的css选择器
fileInputselector:  文件框的css选择器
files:  需要上传文件的路径数组


//参数示例
{
tabId: 123654,
iframeselector:"#iframe",
fileInputselector:"#fileInput",
files:["C:/Users/Administrator/Desktop/11.png"]
}
网页上传文件(MV3版iframe可行方案) - Quicker

浏览器插件跨框架(frame)上传文件的方法 - Quicker

回复主贴