playwright
playwright copied to clipboard
[Feature] Preferences API
Currently, Playwright only supports conveniently setting command line switches for the browser. Some features cannot be controlled via these switches and it's instead necessary to user persistent context with some magic prefs.json, it would be nice to be able to do something like:
await browser.newContext({
preferences: { key: val, …}
})
where preferences is an arbitrary dict that PW handles seeding into the correct location in the user data directory. IMO, this is basically the same feature as the args: […] option, but supports more customization of the browser.
Some uses that have come up:
- customize cookie setting to test site under different cookie profiles
- disable native PDF viewer
Yes, I love this idea. I would love to test a case were enabling blocking third party cookies also blanks accessing localStorage. I would like to test with and without this blocking enabled as part of regression tests to avoid accidental breaking things.
@JoelEinbinder If this is something the Playwright team is on board with, I'd be interested in helping contribute it.
Off the top of your head (if not I can do some research if this seems like something the PW team is willing to accept), are FF and WK similar to CR in that there is theoretically a file that drives the prefs/settings at launch per-context?
Cheers!
I don't want to encourage people to rely on the raw preferences, especially in our browser forms. For chromium, I don't think there are canonical names for preferences like blocking third party cookies. They might break from release to release.
That being said it would enable a lot of functionality. So if it works and it's safe I'd have trouble arguing against it.
Sounds good! I'd position this as an escape hatch (just like args in https://playwright.dev/docs/api/class-browsertype#browser-type-launch). If there is a formal Playwright setting (like proxy) one should use that, but if there's no option you could use this. Proxy options can be set with CLI flags via args, but luckily Playwright has a specific, well-typed, cross-browser option for that. The same cannot be said for a lot of the other bits of browser that one can customize.
Hope to support this requirement
+1
Please add 👍 or ❤️ to the original comment instead of adding new comments. Emoji reactions matter because issues can be sorted by them, thus helping the team with backlog prioritising. Empty comments only generate spam in GitHub notifications for folks who are subscribed to this issue 🙏
Why was this issue closed?
Thank you for your involvement. This issue was closed due to limited engagement (upvotes/activity), lack of recent activity, and insufficient actionability. To maintain a manageable database, we prioritize issues based on these factors.
If you disagree with this closure, please open a new issue and reference this one. More support or clarity on its necessity may prompt a review. Your understanding and cooperation are appreciated.
This issue is in top-10 by the number of ❤️ reactions received at all times:
This feature request did not get any 👍, but if imagine all ❤️ replaced by 👍, it would be on the fourth page of all currently open issues (out of 25):
If this issue was closed mechanically based on the number of 👍, could this decision be reconsidered please? 🙏