[REGRESSION]: Types for BrowserTypeLaunchOptions and BrowserContextCookies are not exported
See original GitHub issueContext:
- GOOD Playwright Version: 0.12.1
- BAD Playwright Version: 0.13.0
Code Snippet
import { BrowserContextCookies, BrowserTypeLaunchOptions } from 'playwright';
Describe the bug
These types are no longer available.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (8 by maintainers)
Top Results From Across the Web
[BUG] browserContext.cookies() doesn't return all ... - GitHub
[BUG] browserContext.cookies() doesn't return all cookies #12967 ... module.exports = async (config) => { const browser = await ...
Read more >Changelog - Cypress Documentation
Caching and restoring cookies, localStorage , and sessionStorage between tests; Configuring testIsolation in suites to define whether or not the browser context ......
Read more >Why can't I get cookie value in Playwright? - Stack Overflow
In your second method, change cookies = context.cookies to cookies = context.cookies() . It's a method, you need to call it.
Read more >BrowserType (Playwright - Main Library 1.22.0 API) - javadoc.io
Browser · launch(BrowserType.LaunchOptions options). Returns the browser instance. ; default BrowserContext · launchPersistentContext(Path userDataDir). Returns ...
Read more >Playwright.BrowserContext — playwright v1.18.0-alpha.1
create a new "incognito" browser context: context = Playwright. ... Register a (non-blocking) callback/handler for various types of events. pages(context).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For one-off use cases, you can still get the types by using TypeScript’s
Parameters
type.This has the benefit of being guaranteed to work forever, even if the signature of
page.goto
changes. The downside is that it looks fairly ugly.With the previous types, we were generating and exporting all of the object types inside of the api. The upside of this is that you get everything. The downsides are that there is a lot of useless types adding noise to the API, and it options us up to introducing subtle breaking changes.
PageGotoOptions
andFrameGotoOptions
, are identical. If we merged them, intoGotoOptions
, someone might write code like:Then, if we later added a new option
foo
topage.goto
, but did not addfoo
toframe.goto
, it would be a breaking change. We could solve this by havingGotoOptions
contain the shared options contained bypage.goto
andframe.goto
, and then havingPageGotoOptions
extendGotoOptions
with the same type. This makes our generating process significantly more complicated, because we would need to check not just whether types can be merged, but if and how they were merged in a previously released version of playwright.Perhaps a bigger subtle problem with exporting all of the types was that we add the parameter name into the type name.
BrowserTypeLaunchOptions
ends withOptions
because the first argument tobrowserType.launch
isoptions
. If we were to renamebrowserType.launch(options)
intobrowserType.launch(nameOrOptions)
orbrowserType.launch(opt)
, this usually wouldn’t be a breaking change. But with the generated types it is, because the type name will change.Ways to proceed:
Parameters
.playwright/types
, that contains the types. This might have a different stability contract, where we don’t consider changes here to be breaking.What do you all think?
I’ve opened another issue some days ago, https://github.com/microsoft/playwright/issues/2752, but while searching another thing ended up here. Thanks for the clarification! Just in case, from historical reason from pptr, we use also: ElementHandleScreenshotOptions, PageGotoOptions, PageScreenshotOptions.
This one as well: BrowserTypeLaunchServerOptions