-
Notifications
You must be signed in to change notification settings - Fork 4.1k
feat(codegen): add user-data-dir option #35814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
docs/src/codegen.md
Outdated
@@ -414,6 +414,26 @@ pwsh bin/Debug/netX/playwright.ps1 codegen --load-storage=auth.json github.com/m | |||
|
|||
<img width="1394" alt="github signed in showing use of load storage scharp" src="https://user-images.githubusercontent.com/13063165/220928354-caa0e958-fe09-4125-9b54-67483064da51.png" /> | |||
|
|||
#### Use existing userDataDir | |||
|
|||
Run `codegen` with `--user-data-dir` to set a fixed [user data directory](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context-option-user-data-dir) for the browser session. If you point this at your existing browser's user data directory, codegen will use your existing browser profile and have access to your authentication state. Remember that any authentication that codegen receives from using your browser configuration must be replicated at test time using [fixtures](./test-fixtures.md) or `before*` hooks, otherwise the UI you're trying to evaluate might not be available when executing the test. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure what our practice is for pages like test-fixtures.md
as it only exists in JS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ended up removing the link.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Run `codegen` with `--user-data-dir` to set a fixed [user data directory](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-persistent-context-option-user-data-dir) for the browser session. If you point this at your existing browser's user data directory, codegen will use your existing browser profile and have access to your authentication state. Remember that any authentication that codegen receives from using your browser configuration must be replicated at test time using fixtures or `before*` hooks, otherwise the UI you're trying to evaluate might not be available when executing the test. | ||
|
||
```bash js | ||
npx playwright codegen --user-data-dir=/path/to/your/browser/data/ github.com/microsoft/playwright |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work for a user who has a different profile than 'Default'
. The story is a bit more complicated there that we should teach them how to get this path, what is 'Default'
etc. I wonder if we want to enter this territory or if we should rely on third-party blog posts like this one. The main customers of this are Chromium anyways and doing this with page.pause()
seems to have worked fine in the past.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Test results for "tests 1"1 failed 3 flaky39126 passed, 803 skipped Merge workflow run. |
Introduces
codegen --user-data-dir
option to allow specification of an existing browser profile directory to use during codegen.Resolves #35617.