@auto-wiz/playwright 1.1.0 → 1.1.3

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 +31 -2
  2. package/package.json +2 -2
package/dist/runner.js CHANGED
@@ -99,8 +99,8 @@ class PlaywrightFlowRunner {
99
99
  else if (step.prop === "innerText") {
100
100
  text = await locator.innerText({ timeout });
101
101
  }
102
- else {
103
- // Default match 'outerHTML' if prop is not specified or explicit 'outerHTML'
102
+ else if (step.prop === "outerHTML") {
103
+ // Explicit 'outerHTML' requests full HTML (with SVGs stripped per existing logic)
104
104
  text = await locator.evaluate((el) => {
105
105
  const clone = el.cloneNode(true);
106
106
  const svgs = clone.querySelectorAll("svg");
@@ -108,6 +108,35 @@ class PlaywrightFlowRunner {
108
108
  return clone.outerHTML;
109
109
  });
110
110
  }
111
+ else {
112
+ // Default "structure": clean HTML, keep only id, name, text
113
+ text = await locator.evaluate(function (el) {
114
+ const clone = el.cloneNode(true);
115
+ // 1. Remove SVGs first
116
+ const svgs = clone.querySelectorAll("svg");
117
+ for (const svg of Array.from(svgs)) {
118
+ svg.remove();
119
+ }
120
+ // 2. Clean attributes of all descendants
121
+ const descendants = clone.querySelectorAll("*");
122
+ for (const child of Array.from(descendants)) {
123
+ const attrs = Array.from(child.attributes);
124
+ for (const attr of attrs) {
125
+ if (attr.name !== "id" && attr.name !== "name") {
126
+ child.removeAttribute(attr.name);
127
+ }
128
+ }
129
+ }
130
+ // 3. Clean attributes of the root element itself
131
+ const rootAttrs = Array.from(clone.attributes);
132
+ for (const attr of rootAttrs) {
133
+ if (attr.name !== "id" && attr.name !== "name") {
134
+ clone.removeAttribute(attr.name);
135
+ }
136
+ }
137
+ return clone.outerHTML;
138
+ });
139
+ }
111
140
  return { success: true, extractedData: text?.trim() };
112
141
  }
113
142
  case "waitFor": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auto-wiz/playwright",
3
- "version": "1.1.0",
3
+ "version": "1.1.3",
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.1.0"
27
+ "@auto-wiz/core": "1.1.3"
28
28
  },
29
29
  "devDependencies": {
30
30
  "typescript": "^5.0.0",