Microsoft Technologies based on the .NET software framework. Miscellaneous topics that do not fit into specific categories.
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
codegenwith--save-storageto save cookies... pwsh bin/Debug/netX/playwright.ps1 codegen --save-storage=auth.json" "Run with--load-storageto 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.