@one2x/playwright 1.57.0-alpha.16 → 1.57.0-alpha.18
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.
|
@@ -180,15 +180,47 @@ const inspectAtXY = (0, import_tool.defineTabTool)({
|
|
|
180
180
|
}
|
|
181
181
|
return true;
|
|
182
182
|
});
|
|
183
|
+
const consolidatedElements = [];
|
|
184
|
+
const svgSet = /* @__PURE__ */ new Set();
|
|
185
|
+
for (const element of meaningfulElements) {
|
|
186
|
+
let current = element;
|
|
187
|
+
let parentSVG = null;
|
|
188
|
+
while (current) {
|
|
189
|
+
if (current.tagName === "svg") {
|
|
190
|
+
parentSVG = current;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
current = current.parentElement;
|
|
194
|
+
}
|
|
195
|
+
if (parentSVG) {
|
|
196
|
+
if (!svgSet.has(parentSVG)) {
|
|
197
|
+
svgSet.add(parentSVG);
|
|
198
|
+
consolidatedElements.push(parentSVG);
|
|
199
|
+
}
|
|
200
|
+
} else {
|
|
201
|
+
consolidatedElements.push(element);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
183
204
|
const sortedElements = [];
|
|
184
205
|
const processed = /* @__PURE__ */ new Set();
|
|
185
|
-
const
|
|
206
|
+
const consolidatedSet = new Set(consolidatedElements);
|
|
186
207
|
for (const point of points) {
|
|
187
208
|
const elements = document.elementsFromPoint(point.x, point.y);
|
|
188
209
|
for (const el of elements) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
210
|
+
let elementToCheck = el;
|
|
211
|
+
if (el.tagName !== "svg") {
|
|
212
|
+
let current = el;
|
|
213
|
+
while (current) {
|
|
214
|
+
if (current.tagName === "svg") {
|
|
215
|
+
elementToCheck = current;
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
current = current.parentElement;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (consolidatedSet.has(elementToCheck) && !processed.has(elementToCheck)) {
|
|
222
|
+
sortedElements.push(elementToCheck);
|
|
223
|
+
processed.add(elementToCheck);
|
|
192
224
|
}
|
|
193
225
|
}
|
|
194
226
|
}
|
|
@@ -294,6 +326,30 @@ const inspectAtXY = (0, import_tool.defineTabTool)({
|
|
|
294
326
|
const distanceToCenter = Math.sqrt(
|
|
295
327
|
Math.pow(elementCenterX - centerPoint.x, 2) + Math.pow(elementCenterY - centerPoint.y, 2)
|
|
296
328
|
);
|
|
329
|
+
let svgColors = null;
|
|
330
|
+
if (element.tagName.toLowerCase() === "svg") {
|
|
331
|
+
const colorSet = /* @__PURE__ */ new Set();
|
|
332
|
+
const fillSet = /* @__PURE__ */ new Set();
|
|
333
|
+
const strokeSet = /* @__PURE__ */ new Set();
|
|
334
|
+
const allDescendants = element.querySelectorAll("*");
|
|
335
|
+
for (const descendant of Array.from(allDescendants)) {
|
|
336
|
+
const style = window.getComputedStyle(descendant);
|
|
337
|
+
const fill = descendant.getAttribute("fill") || style.fill;
|
|
338
|
+
if (fill && fill !== "none" && fill !== "transparent" && !fill.startsWith("url("))
|
|
339
|
+
fillSet.add(fill);
|
|
340
|
+
const stroke = descendant.getAttribute("stroke") || style.stroke;
|
|
341
|
+
if (stroke && stroke !== "none" && stroke !== "transparent" && !stroke.startsWith("url("))
|
|
342
|
+
strokeSet.add(stroke);
|
|
343
|
+
const color = style.color;
|
|
344
|
+
if (color && color !== "transparent")
|
|
345
|
+
colorSet.add(color);
|
|
346
|
+
}
|
|
347
|
+
svgColors = {
|
|
348
|
+
colors: Array.from(colorSet),
|
|
349
|
+
fills: Array.from(fillSet),
|
|
350
|
+
strokes: Array.from(strokeSet)
|
|
351
|
+
};
|
|
352
|
+
}
|
|
297
353
|
return {
|
|
298
354
|
ref: ariaRef?.ref || null,
|
|
299
355
|
role: ariaRef?.role || null,
|
|
@@ -303,6 +359,7 @@ const inspectAtXY = (0, import_tool.defineTabTool)({
|
|
|
303
359
|
bounds,
|
|
304
360
|
containsCenterPoint,
|
|
305
361
|
distanceToCenter,
|
|
362
|
+
svgColors,
|
|
306
363
|
computedStyles: {
|
|
307
364
|
display: computedStyle.display,
|
|
308
365
|
visibility: computedStyle.visibility,
|
|
@@ -448,6 +505,29 @@ ${elementInfo.truncatedHTML}
|
|
|
448
505
|
if (!elementInfo.containsCenterPoint)
|
|
449
506
|
result += `- Distance to center: ${Math.round(elementInfo.distanceToCenter)}px
|
|
450
507
|
`;
|
|
508
|
+
if (elementInfo.svgColors) {
|
|
509
|
+
result += `
|
|
510
|
+
**SVG Colors (from descendants):**
|
|
511
|
+
`;
|
|
512
|
+
if (elementInfo.svgColors.fills.length > 0)
|
|
513
|
+
result += `- Fill colors: ${elementInfo.svgColors.fills.join(", ")}
|
|
514
|
+
`;
|
|
515
|
+
else
|
|
516
|
+
result += `- Fill colors: none
|
|
517
|
+
`;
|
|
518
|
+
if (elementInfo.svgColors.strokes.length > 0)
|
|
519
|
+
result += `- Stroke colors: ${elementInfo.svgColors.strokes.join(", ")}
|
|
520
|
+
`;
|
|
521
|
+
else
|
|
522
|
+
result += `- Stroke colors: none
|
|
523
|
+
`;
|
|
524
|
+
if (elementInfo.svgColors.colors.length > 0)
|
|
525
|
+
result += `- Text colors: ${elementInfo.svgColors.colors.join(", ")}
|
|
526
|
+
`;
|
|
527
|
+
else
|
|
528
|
+
result += `- Text colors: none
|
|
529
|
+
`;
|
|
530
|
+
}
|
|
451
531
|
result += `
|
|
452
532
|
**Key Computed Styles:**
|
|
453
533
|
`;
|
|
@@ -88,13 +88,11 @@ const click = (0, import_tool.defineTabTool)({
|
|
|
88
88
|
options
|
|
89
89
|
);
|
|
90
90
|
});
|
|
91
|
-
if (
|
|
92
|
-
return;
|
|
93
|
-
if (result.mode === "auto" && result.interceptorInfo) {
|
|
91
|
+
if (result?.mode === "auto" && result.interceptorInfo) {
|
|
94
92
|
const actionName = params.doubleClick ? ".dblclick({ allowIntercept: true })" : ".click({ allowIntercept: true })";
|
|
95
93
|
(0, import_utils.addInterceptorWarning)(response, resolved, actionName, result.interceptorInfo);
|
|
96
94
|
}
|
|
97
|
-
const needsAllowIntercept = result
|
|
95
|
+
const needsAllowIntercept = result?.mode === "auto" && result.interceptorInfo || result?.mode === "always";
|
|
98
96
|
const finalOptions = needsAllowIntercept ? { ...options, allowIntercept: true } : options;
|
|
99
97
|
const formatted = javascript.formatObject(finalOptions, " ", "oneline");
|
|
100
98
|
const optionsAttr = formatted !== "{}" ? formatted : "";
|
|
@@ -132,11 +130,9 @@ const drag = (0, import_tool.defineTabTool)({
|
|
|
132
130
|
{}
|
|
133
131
|
);
|
|
134
132
|
});
|
|
135
|
-
if (
|
|
136
|
-
return;
|
|
137
|
-
if (result.mode === "auto" && result.interceptorInfo)
|
|
133
|
+
if (result?.mode === "auto" && result.interceptorInfo)
|
|
138
134
|
(0, import_utils.addInterceptorWarning)(response, start.resolved, ".dragTo(target, { allowIntercept: true })", result.interceptorInfo);
|
|
139
|
-
const needsAllowIntercept = result
|
|
135
|
+
const needsAllowIntercept = result?.mode === "auto" && result.interceptorInfo || result?.mode === "always";
|
|
140
136
|
const optionsAttr = needsAllowIntercept ? ", { allowIntercept: true }" : "";
|
|
141
137
|
response.addCode(`await page.${start.resolved}.dragTo(page.${end.resolved}${optionsAttr});`);
|
|
142
138
|
response.setIncludeAutoScreenshot();
|
|
@@ -161,11 +157,9 @@ const hover = (0, import_tool.defineTabTool)({
|
|
|
161
157
|
{}
|
|
162
158
|
);
|
|
163
159
|
});
|
|
164
|
-
if (
|
|
165
|
-
return;
|
|
166
|
-
if (result.mode === "auto" && result.interceptorInfo)
|
|
160
|
+
if (result?.mode === "auto" && result.interceptorInfo)
|
|
167
161
|
(0, import_utils.addInterceptorWarning)(response, resolved, ".hover({ allowIntercept: true })", result.interceptorInfo);
|
|
168
|
-
const needsAllowIntercept = result
|
|
162
|
+
const needsAllowIntercept = result?.mode === "auto" && result.interceptorInfo || result?.mode === "always";
|
|
169
163
|
const optionsAttr = needsAllowIntercept ? "{ allowIntercept: true }" : "";
|
|
170
164
|
response.addCode(`await page.${resolved}.hover(${optionsAttr});`);
|
|
171
165
|
response.setIncludeAutoScreenshot();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@one2x/playwright",
|
|
3
|
-
"version": "1.57.0-alpha.
|
|
3
|
+
"version": "1.57.0-alpha.18",
|
|
4
4
|
"description": "A high-level API to automate web browsers",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"license": "Apache-2.0",
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"content-type": "^1.0.5",
|
|
68
|
-
"playwright-core": "npm:@one2x/playwright-core@1.57.0-alpha.
|
|
68
|
+
"playwright-core": "npm:@one2x/playwright-core@1.57.0-alpha.18",
|
|
69
69
|
"raw-body": "^2.5.2"
|
|
70
70
|
},
|
|
71
71
|
"optionalDependencies": {
|