Playwright for .NET Recorder/Inspector is giving me several problems.

Falanga, Rod, DOH 1,190 Reputation points
2026-08-03T17:39:21.4833333+00:00

I am certain that I ran playwright.ps1 from .\bin\Debug\net10.0\playwright.ps1, but every time I tried to run the codegen command, it always complained:

.\bin\Debug\net10.0\codegen: The term '.\bin\Debug\net10.0\codegen' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

So, then I tried putting playwright.ps1 before codegen and I kept getting that error. I was trying to use the Developer PowerShell prompt.

So, then I thought I was run the installation again. So, from the .\bin\Debug\net10.0 folder I ran playwright.ps1 install. I guess it worked, because there were no errors; the prompt came back. However, trying to run codegen without playwright.ps1 or with playwright.ps1 continued to bring up the same errors.

So, then I opened Microsoft Terminal, got into PowerShell 7, went into .\bin\Debug\net10.0 folder, and ran playwright.ps1 codegen https://thewebsite/Rod and that finally worked. (If I left off playwright.ps1 it refused to work but gave me the same error message.) But now I've got a different problem. I'm going to the Rod page, where it should read a cookie and populate a dropdown with the selected value. But it doesn't!! No matter what I do, it refuses to read the cookie. From my point of view, Playwright is a useless technology, if I cannot use it as any user would use the app.

So, why doesn't Playwright's codegen work as examples I see in several places online demonstrate how to use it?

Why did I have to re-install playwright?

Did I really have to re-install playwright, or is it the case that I had to pat my head and rub my stomach on a counterclockwise fashion, in order to make it work? (I'm being silly, I know, but all of these caveats, which are not mentioned in places like Pluralsight training, etc. is hugely frustrating. I cannot read minds. I need to have how to use it spelled out correctly from the beginning.)

And finally, once I got Playwright's codegen and inspector working, why won't it read an HTML cookie, like the application is written to work and it does work, when not using Playwright?

Developer technologies | .NET | Other

Answer accepted by question author
Taki Ly (WICLOUD CORPORATION) 4,360 Reputation points Microsoft External Staff Moderator
2026-08-04T03:32:11.5833333+00:00

Hello @Falanga, Rod, DOH ,

Thank you for sharing your experience in detail.

Regarding the command failing without playwright.ps1, the official Playwright .NET documentation notes that codegen is an argument that must be passed to the PowerShell script, rather than a standalone executable. As seen in the Test Generator documentation, the correct syntax requires the script:

"pwsh bin/Debug/netX/playwright.ps1 codegen"

When you ran the install command, it might be helpful to know that you weren't actually reinstalling the library. According to the Browsers documentation, this step is a standard requirement to download the underlying browser files:

"Each version of Playwright needs specific versions of browser binaries to operate. You will need to use the Playwright CLI to install these browsers... pwsh bin/Debug/netX/playwright.ps1 install"

For the issue with reading your application's HTML cookie, this suggests it is related to Playwright's strict "Test Isolation" design. The Isolation documentation explains that Playwright launches every session in a new "Browser Context," which acts exactly like a fresh Incognito profile:

"Test Isolation is when each test is completely isolated from another test... This means that each test has its own local storage, session storage, cookies etc."

To allow your application to read the required cookies, it might be beneficial to use Playwright's state preservation feature. The documentation on Preserving Authenticated State suggests running codegen once to capture the cookie, and then loading it on subsequent runs:

"Run codegen with --save-storage to save cookies... pwsh bin/Debug/netX/playwright.ps1 codegen --save-storage=auth.json" "Run with --load-storage to consume the previously loaded storage... all cookies, localStorage and IndexedDB data will be restored"

I hope these documentation references help clarify the tool's intended design. If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation.

Thank you.

Was this answer helpful?

1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Jay Pham (WICLOUD CORPORATION) 4,355 Reputation points Microsoft External Staff Moderator
    2026-08-04T00:13:25.5466667+00:00

    We are currently working the issue and will provide an update soon. Thank you for your patience.

    Was this answer helpful?

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.