Skip to content

Support for Playwright “codegen” (test generation) with Serenity Screenplay Pattern #3732

Description

@GauravKumar52

What's the Problem You're Trying to Solve?

Description

We are currently using Serenity BDD Screenplay pattern with Playwright (Java + Maven) for our automation framework.

Playwright provides a powerful feature called codegen (test generator) that records user interactions and generates test scripts automatically. This is extremely helpful for:

Faster test development
Easy locator identification
Debugging and prototyping flows

However, this feature currently generates plain Playwright code, which does not align with the Screenplay pattern used in Serenity.

Current Limitation
Playwright codegen generates:
Raw Playwright API calls (page.click, locator.fill, etc.)
Serenity Screenplay requires:
Abstraction via Tasks, Interactions, and Targets
Actor-based execution model

➡️ There is no direct way to convert or generate Screenplay-compatible code from Playwright codegen output.

Expectation / Question

Is there any existing or planned support to:

Integrate Playwright codegen with Serenity Screenplay
Provide a utility/tool to:
Convert generated Playwright code into Screenplay pattern
Or generate Task / Interaction classes automatically
Enhance Serenity Playwright module to support record-and-generate workflow

Use Case

In large automation projects:

Teams want to quickly record flows using Playwright
Then convert them into maintainable Screenplay-based tests

Currently, this requires manual effort, which:

Slows down development
Introduces inconsistency in abstraction
Reduces benefits of Playwright tooling

Proposed Solution

Suggested Approach (Optional Enhancement)
A CLI or plugin that:
Parses Playwright codegen output
Maps actions to Screenplay Performable classes
OR a Serenity extension that:
Hooks into Playwright recording
Generates Screenplay-friendly structure directly
Impact
Improves developer productivity significantly
Encourages adoption of Serenity + Playwright
Bridges gap between low-level recording and high-level design pattern
Additional Context

This feature would be particularly valuable for teams:

Migrating from Selenium to Playwright
Adopting Screenplay pattern
Working with frequent UI changes and needing rapid test creation

Request:
Please confirm if this capability is:

Already available (via plugin/extension)
Planned in future roadmap
Or recommended workaround approach

Alternative Solutions

No response

Implementation Support

  • Contribute the feature myself (with guidance from the Serenity BDD team)
  • Hire the Serenity BDD team for implementation
  • Add it to the Serenity BDD backlog and wait for community contribution

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions