BidiBrowserContext
Namespace: PuppeteerSharp.Bidi
public class BidiBrowserContext : BrowserContext, IBrowserContext, IDisposable, IAsyncDisposableSupports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.
Inheritance: object → BrowserContext
Implements: IBrowserContext, IDisposable, IAsyncDisposable
Methods
Section titled “Methods”ClearPermissionOverridesAsync()
Section titled “ClearPermissionOverridesAsync()”public override Task ClearPermissionOverridesAsync()Clears all permission overrides for the browser context.
Returns: Task — The task.
CloseAsync()
Section titled “CloseAsync()”public override Task CloseAsync()Closes the browser context. All the targets that belong to the browser context will be closed.
Returns: Task — Task.
GetCookiesAsync()
Section titled “GetCookiesAsync()”public override Task<CookieParam[]> GetCookiesAsync()Gets all cookies in the browser context.
Returns: Task<CookieParam[]> — Task which resolves to an array of CookieParam.
NewPageAsync(CreatePageOptions)
Section titled “NewPageAsync(CreatePageOptions)”public override Task<IPage> NewPageAsync(CreatePageOptions options = null)Creates a new page.
Parameters
| Name | Type | Description |
|---|---|---|
options |
CreatePageOptions | Options for creating the page. |
Returns: Task<IPage> — Task which resolves to a new IPage object.
OverridePermissionsAsync(string, IEnumerable<OverridePermission>)
Section titled “OverridePermissionsAsync(string, IEnumerable<OverridePermission>)”public override Task OverridePermissionsAsync(string origin, IEnumerable<OverridePermission> permissions)Overrides the browser context permissions.
Parameters
| Name | Type | Description |
|---|---|---|
origin |
string | The origin to grant permissions to, e.g. “https://example.com”. |
permissions |
IEnumerable<OverridePermission> | An array of permissions to grant. All permissions that are not listed here will be automatically denied. |
Returns: Task — The task.
Example
var context = browser.DefaultBrowserContext; await context.OverridePermissionsAsync(“https://html5demos.com”, new List<string> {“geolocation”});
PagesAsync(bool)
Section titled “PagesAsync(bool)”public override Task<IPage[]> PagesAsync(bool includeAll = false)An array of all pages inside the browser context.
Parameters
| Name | Type | Description |
|---|---|---|
includeAll |
bool | Experimental. When true, includes all kinds of pages. |
Returns: Task<IPage[]> — Task which resolves to an array of all open pages.
Non visible pages, such as "background_page", will not be listed here.
You can find them using PageAsync().
SetCookieAsync(params CookieData[])
Section titled “SetCookieAsync(params CookieData[])”public override Task SetCookieAsync(params CookieData[] cookies)Sets cookies in the browser context.
Parameters
| Name | Type | Description |
|---|---|---|
cookies |
CookieData\[\] |
Cookies to set. |
Returns: Task — Task.
SetPermissionAsync(string, params PermissionEntry[])
Section titled “SetPermissionAsync(string, params PermissionEntry[])”public override Task SetPermissionAsync(string origin, params PermissionEntry[] permissions)Sets the permission for a specific origin.
Parameters
| Name | Type | Description |
|---|---|---|
origin |
string | The origin to set the permission for, e.g. “https://example.com”. Use “*” for all origins (CDP only). |
permissions |
PermissionEntry\[\] |
The permissions to set. |
Returns: Task — The task.
Targets()
Section titled “Targets()”public override ITarget[] Targets()Gets an array of all active targets inside the browser context.
Returns: ITarget\[\] — An array of all active targets inside the browser context.
Made with love by Dario Kondratiuk