Skip to content

[Bug]: Unable to activate the control with keyboard (Enter/space keys) while recording the playwright script. #35794

Open
@vroopea

Description

@vroopea

Version

1.52.0

Steps to reproduce

  1. Open command prompt/Power shell.
  2. Navigate to the created playwright directory.
  • For example: cd C:\Users\<user>\Downloads\Temp\Playwright\Playwright
  • Note that your location will differ depending on where you created it.
  1. Run the command - npx playwright codegen
  2. Playwright chromium browser will be launched. Open the URL: microsoft.com.
  3. Start recording the script. Navigate the page using tab key and observe whether you can activate any interactive element present on the page or not.

Expected behavior

While recording a script using Playwright Codegen, pressing 'Enter or Spacebar' on a focusable control (e.g., button, link, input) should simulate a valid activation (i.e., a click or form submission) and be recorded as a corresponding interaction in the script

Example:
ts
await page.locator('button#submit').press('Enter'); // or .press('Space')

Should be recorded or result in:
ts
await page.locator('button#submit').click();

Actual behavior

When pressing Enter or Spacebar on a focusable control during Playwright Codegen recording, no interaction is triggered or recorded. The control does not respond as expected, and the action is not captured in the generated script.

Actual result_Unable to activate the 'All microsoft' control with keyboard..txt

Actual result_All microsoft control is activated with mouse.txt

Additional context

No response

Environment

System:
OS: Version 24H2 (OS Build 26100.3915)

dotnet SDK:
Microsoft.DotNet.SDK.9

Browser:
Chromium

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions