Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: nit press fix (#38934)

Pavel Feldman56d7bbfd89e1
diff --git a/packages/playwright/src/mcp/browser/tools/keyboard.ts b/packages/playwright/src/mcp/browser/tools/keyboard.ts
index d6b9bc712c..c0901e60c0 100644
--- a/packages/playwright/src/mcp/browser/tools/keyboard.ts
+++ b/packages/playwright/src/mcp/browser/tools/keyboard.ts
@@ -34,7 +34,14 @@ const press = defineTabTool({
handle: async (tab, params, response) => {
response.addCode(`// Press ${params.key}`);
response.addCode(`await page.keyboard.press('${params.key}');`);
- await tab.page.keyboard.press(params.key);
+ if (params.key === 'Enter') {
+ response.setIncludeSnapshot();
+ await tab.waitForCompletion(async () => {
+ await tab.page.keyboard.press('Enter');
+ });
+ } else {
+ await tab.page.keyboard.press(params.key);
+ }
},
});
diff --git a/packages/playwright/src/mcp/terminal/SKILL.md b/packages/playwright/src/mcp/terminal/SKILL.md
index a4f8489a64..42540bc2eb 100644
--- a/packages/playwright/src/mcp/terminal/SKILL.md
+++ b/packages/playwright/src/mcp/terminal/SKILL.md
@@ -18,9 +18,8 @@ playwright-cli press Enter
## Core workflow
1. Navigate: `playwright-cli open https://example.com`
-2. Snapshot: `playwright-cli snapshot` (returns elements with refs like `ref=e1`, `ref=e2`)
-3. Interact using refs from the snapshot
-4. Re-snapshot after navigation or significant DOM changes
+2. Interact using refs from the snapshot
+3. Re-snapshot after significant changes
## Commands