@auto-wiz/playwright 1.0.1 → 1.1.1

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.
Files changed (2) hide show
  1. package/dist/runner.js +35 -6
  2. package/package.json +2 -2
package/dist/runner.js CHANGED
@@ -93,18 +93,47 @@ class PlaywrightFlowRunner {
93
93
  case "extract": {
94
94
  const locator = await this.resolveLocator(page, step, timeout);
95
95
  let text = null;
96
- if (step.prop === "outerHTML") {
97
- text = await locator.evaluate((el) => el.outerHTML);
98
- }
99
- else if (step.prop === "value") {
96
+ if (step.prop === "value") {
100
97
  text = await locator.inputValue();
101
98
  }
102
99
  else if (step.prop === "innerText") {
103
100
  text = await locator.innerText({ timeout });
104
101
  }
102
+ else if (step.prop === "outerHTML") {
103
+ // Explicit 'outerHTML' requests full HTML (with SVGs stripped per existing logic)
104
+ text = await locator.evaluate((el) => {
105
+ const clone = el.cloneNode(true);
106
+ const svgs = clone.querySelectorAll("svg");
107
+ svgs.forEach((svg) => svg.remove());
108
+ return clone.outerHTML;
109
+ });
110
+ }
105
111
  else {
106
- // Default match 'outerHTML' if prop is not specified
107
- text = await locator.evaluate((el) => el.outerHTML);
112
+ // Default "structure": clean HTML, keep only id, name, text
113
+ text = await locator.evaluate((el) => {
114
+ const clone = el.cloneNode(true);
115
+ function cleanElement(element) {
116
+ // Remove all attributes except id and name
117
+ const attributes = Array.from(element.attributes);
118
+ for (const attr of attributes) {
119
+ if (!["id", "name"].includes(attr.name)) {
120
+ element.removeAttribute(attr.name);
121
+ }
122
+ }
123
+ // DFS for children
124
+ for (const child of Array.from(element.children)) {
125
+ // Remove SVGs entirely
126
+ if (child.tagName.toLowerCase() === "svg") {
127
+ child.remove();
128
+ }
129
+ else {
130
+ cleanElement(child);
131
+ }
132
+ }
133
+ }
134
+ cleanElement(clone);
135
+ return clone.outerHTML;
136
+ });
108
137
  }
109
138
  return { success: true, extractedData: text?.trim() };
110
139
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auto-wiz/playwright",
3
- "version": "1.0.1",
3
+ "version": "1.1.1",
4
4
  "license": "MIT",
5
5
  "author": "JaeSang",
6
6
  "repository": {
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "playwright": "^1.40.0",
27
- "@auto-wiz/core": "1.0.1"
27
+ "@auto-wiz/core": "1.1.1"
28
28
  },
29
29
  "devDependencies": {
30
30
  "typescript": "^5.0.0",