chrome-cdp-cli 2.0.5 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/ArgumentParser.js +172 -92
- package/dist/cli/CLIApplication.js +155 -82
- package/dist/cli/CommandRouter.js +98 -74
- package/dist/cli/CommandSchemaRegistry.js +506 -398
- package/dist/cli/HelpSystem.js +286 -256
- package/dist/handlers/ClickHandler.js +91 -27
- package/dist/handlers/InstallClaudeSkillHandler.js +220 -220
- package/dist/handlers/InstallCursorCommandHandler.js +60 -60
- package/dist/handlers/ListConsoleMessagesHandler.js +126 -178
- package/dist/handlers/ListNetworkRequestsHandler.js +128 -108
- package/dist/handlers/RestartProxyHandler.js +4 -4
- package/dist/handlers/TakeScreenshotHandler.js +70 -59
- package/dist/handlers/TakeSnapshotHandler.js +223 -165
- package/dist/handlers/index.js +0 -1
- package/dist/monitors/ConsoleMonitor.js +29 -0
- package/dist/monitors/NetworkMonitor.js +43 -19
- package/dist/proxy/server/CDPProxyServer.js +5 -1
- package/dist/proxy/server/CommandExecutionService.js +1 -1
- package/dist/proxy/server/ProxyAPIServer.js +11 -6
- package/package.json +3 -2
|
@@ -114,35 +114,99 @@ class ClickHandler {
|
|
|
114
114
|
error: `Element with selector "${selector}" not found`
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
117
|
+
try {
|
|
118
|
+
await client.send('Input.dispatchMouseEvent', {
|
|
119
|
+
type: 'mousePressed',
|
|
120
|
+
x: coords.x,
|
|
121
|
+
y: coords.y,
|
|
122
|
+
button: 'left',
|
|
123
|
+
clickCount: 1
|
|
124
|
+
});
|
|
125
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
126
|
+
await client.send('Input.dispatchMouseEvent', {
|
|
127
|
+
type: 'mouseReleased',
|
|
128
|
+
x: coords.x,
|
|
129
|
+
y: coords.y,
|
|
130
|
+
button: 'left',
|
|
131
|
+
clickCount: 1
|
|
132
|
+
});
|
|
133
|
+
return {
|
|
134
|
+
success: true,
|
|
135
|
+
data: {
|
|
136
|
+
selector: selector,
|
|
137
|
+
element: {
|
|
138
|
+
success: true,
|
|
139
|
+
tagName: coords.tagName,
|
|
140
|
+
id: coords.id,
|
|
141
|
+
className: coords.className
|
|
142
|
+
},
|
|
143
|
+
method: 'Input.dispatchMouseEvent',
|
|
144
|
+
coordinates: { x: coords.x, y: coords.y }
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
catch (inputError) {
|
|
149
|
+
const fallbackExpression = `
|
|
150
|
+
(function() {
|
|
151
|
+
const e = document.querySelector('${escapedSelector}');
|
|
152
|
+
if (!e) return { success: false, error: 'Element not found' };
|
|
153
|
+
const r = e.getBoundingClientRect();
|
|
154
|
+
const p = { x: r.left + r.width / 2, y: r.top + r.height / 2 };
|
|
155
|
+
const topEl = document.elementFromPoint(p.x, p.y);
|
|
156
|
+
if (topEl) {
|
|
157
|
+
topEl.dispatchEvent(new MouseEvent('click', {
|
|
158
|
+
bubbles: true,
|
|
159
|
+
cancelable: true,
|
|
160
|
+
view: window,
|
|
161
|
+
clientX: p.x,
|
|
162
|
+
clientY: p.y,
|
|
163
|
+
button: 0
|
|
164
|
+
}));
|
|
165
|
+
return {
|
|
133
166
|
success: true,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
167
|
+
tagName: e.tagName,
|
|
168
|
+
id: e.id,
|
|
169
|
+
className: e.className,
|
|
170
|
+
topElementTag: topEl.tagName
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
return { success: false, error: 'No element at point' };
|
|
174
|
+
})()
|
|
175
|
+
`;
|
|
176
|
+
const fallbackResponse = await client.send('Runtime.evaluate', {
|
|
177
|
+
expression: fallbackExpression,
|
|
178
|
+
returnByValue: true,
|
|
179
|
+
userGesture: true
|
|
180
|
+
});
|
|
181
|
+
if (fallbackResponse.exceptionDetails) {
|
|
182
|
+
return {
|
|
183
|
+
success: false,
|
|
184
|
+
error: `Input click failed and fallback also failed: ${fallbackResponse.exceptionDetails.exception?.description || fallbackResponse.exceptionDetails.text}`
|
|
185
|
+
};
|
|
144
186
|
}
|
|
145
|
-
|
|
187
|
+
const fallbackResult = fallbackResponse.result.value;
|
|
188
|
+
if (!fallbackResult.success) {
|
|
189
|
+
return {
|
|
190
|
+
success: false,
|
|
191
|
+
error: `Input click failed and fallback failed: ${fallbackResult.error || 'Unknown error'}`
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return {
|
|
195
|
+
success: true,
|
|
196
|
+
data: {
|
|
197
|
+
selector: selector,
|
|
198
|
+
element: {
|
|
199
|
+
success: true,
|
|
200
|
+
tagName: fallbackResult.tagName || coords.tagName,
|
|
201
|
+
id: fallbackResult.id || coords.id,
|
|
202
|
+
className: fallbackResult.className || coords.className
|
|
203
|
+
},
|
|
204
|
+
method: 'dispatchEvent (fallback)',
|
|
205
|
+
coordinates: { x: coords.x, y: coords.y },
|
|
206
|
+
topElementTag: fallbackResult.topElementTag
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
}
|
|
146
210
|
}
|
|
147
211
|
catch (error) {
|
|
148
212
|
return {
|