diff --git a/playwriter/src/htmlrewrite.test.ts b/playwriter/src/htmlrewrite.test.ts
index 31f38e1..f3e2654 100644
--- a/playwriter/src/htmlrewrite.test.ts
+++ b/playwriter/src/htmlrewrite.test.ts
@@ -13965,6 +13965,24 @@ test('always keeps test ID attributes', async () => {
`)
})
+test('keeps all common e2e test ID attributes', async () => {
+ const html = `
+
+
+ Text
+
+ `
+ const result = await formatHtmlForPrompt({ html })
+
+ expect(result).toMatchInlineSnapshot(`
+ "
+
+ Text
+
+ "
+ `)
+})
+
test('processes x.com.html with size savings', async () => {
const html = readFileSync(new URL('./assets/x.com.html', import.meta.url), 'utf-8')
diff --git a/playwriter/src/htmlrewrite.ts b/playwriter/src/htmlrewrite.ts
index 5ea6955..4bbbbd8 100644
--- a/playwriter/src/htmlrewrite.ts
+++ b/playwriter/src/htmlrewrite.ts
@@ -52,9 +52,18 @@ export async function formatHtmlForPrompt({
'aria-pressed',
'aria-required',
'aria-current',
- // Test IDs (data-testid, data-test, data-cy are covered by data-* prefix)
+ // Test IDs (data-testid, data-test, data-cy, data-qa are covered by data-* prefix)
'testid',
'test-id',
+ 'tid',
+ 'qa',
+ 'qa-id',
+ 'e2e',
+ 'e2e-id',
+ 'automation-id',
+ 'automationid',
+ 'selenium',
+ 'pw',
'vimium-label',
// Conditionally added: 'style', 'class'
]
diff --git a/playwriter/src/skill.md b/playwriter/src/skill.md
index d921249..7ce08cd 100644
--- a/playwriter/src/skill.md
+++ b/playwriter/src/skill.md
@@ -469,12 +469,23 @@ const html = await getCleanHTML({ locator: page, search: /button/i })
const diff = await getCleanHTML({ locator: page, showDiffSinceLastCall: true })
```
+**Parameters:**
- `locator` - Playwright Locator or Page to get HTML from
-- `search` - string/regex to filter results (returns first 10 matching lines)
-- `showDiffSinceLastCall` - returns diff since last snapshot
+- `search` - string/regex to filter results (returns first 10 matching lines with 5 lines context)
+- `showDiffSinceLastCall` - returns unified diff since last call for same locator/page. First call stores snapshot and returns message; subsequent calls return the diff. Useful for tracking DOM changes after actions.
- `includeStyles` - keep style and class attributes (default: false)
-Returns cleaned HTML with only essential attributes (aria-*, data-*, href, role, title, alt, etc.). Removes script, style, svg, head tags.
+**HTML processing:**
+The function cleans HTML for compact, readable output:
+- **Removes tags**: script, style, link, meta, noscript, svg, head
+- **Unwraps nested wrappers**: Empty divs/spans with no attributes that only wrap a single child are collapsed (e.g., `
text
` → `
text
`)
+- **Removes empty elements**: Elements with no attributes and no content are removed
+- **Truncates long values**: Attribute values >200 chars and text content >500 chars are truncated
+
+**Attributes kept (summary):**
+- Common semantic and ARIA attributes (e.g., `href`, `name`, `type`, `aria-*`)
+- All `data-*` test attributes
+- Frequently used test IDs and special attributes (e.g., `testid`, `qa`, `e2e`, `vimium-label`)
For pagination, use `.split('\n').slice(offset, offset + limit).join('\n')`:
```js