Skip to content

[BUG] Codegen 1.27 creates NUnit code that does not compile #17960

@jgraber

Description

@jgraber

Context:

  • Playwright Version: 1.27
  • Operating System: Windows
  • .NET version: .NET 6
  • Browser: Chromium & Firefox
  • Extra: -

Code Snippet

The new selectors in version 1.27.0 of codegen creates NUnit code in C# that does not compile.

The generated code to click a link looks like this:

await Page.GetByRole("link", new() { Name = "https://www.insel.ch" }).ClickAsync();

To compile the code, it should look like this:

await Page.GetByRole(AriaRole.Link, new() { NameString = "https://www.insel.ch" }).ClickAsync();

There is “link” instead of AriaRole.Link and “Name” for the property NameString of the PageGetByRoleOptions object.

In codegen version 1.26.0 it created this code that compiled:

await Page.Locator("text=https://www.insel.ch").ClickAsync();

Describe the bug

It looks for me as if the change for the selectors is only partially done in V1.27 and a few cases are missing. You can find the whole generated code in the attached files. (OldVersion.txt is generated with version 1.26 of codegen, CurrentVersion.txt is the output of 1.27 and the manual fixes to make the code compile.)

OldVersion.txt
CurrentVersion.txt

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