pub struct ContextBuilder<'e, 'f, 'g, 'h, 'i, 'j, 'k> {
inner: Weak<Browser>,
args: NewContextArgs<'e, 'f, 'g, 'h, 'i, 'j, 'k>,
}Expand description
Fields§
§inner: Weak<Browser>§args: NewContextArgs<'e, 'f, 'g, 'h, 'i, 'j, 'k>Implementations§
Source§impl<'e, 'f, 'g, 'h, 'i, 'j, 'k> ContextBuilder<'e, 'f, 'g, 'h, 'i, 'j, 'k>
impl<'e, 'f, 'g, 'h, 'i, 'j, 'k> ContextBuilder<'e, 'f, 'g, 'h, 'i, 'j, 'k>
pub async fn build(self) -> Result<BrowserContext, Arc<Error>>
fn new(inner: Weak<Browser>) -> Self
pub fn set_device(self, device: &'e DeviceDescriptor) -> Self
Sourcepub fn accept_downloads(self, x: bool) -> Self
pub fn accept_downloads(self, x: bool) -> Self
Whether to automatically download all the attachments. Defaults to false where all the downloads are canceled.
Sourcepub fn bypass_csp(self, x: bool) -> Self
pub fn bypass_csp(self, x: bool) -> Self
Toggles bypassing page’s Content-Security-Policy.
Sourcepub fn color_scheme(self, x: ColorScheme) -> Self
pub fn color_scheme(self, x: ColorScheme) -> Self
Emulates 'prefers-colors-scheme' media feature, supported values are 'light', 'dark', 'no-preference'. See
[method: Page.emulateMedia] for more details. Defaults to 'light'.
Sourcepub fn device_scale_factor(self, x: f64) -> Self
pub fn device_scale_factor(self, x: f64) -> Self
Specify device scale factor (can be thought of as dpr). Defaults to 1.
Sourcepub fn extra_http_headers(self, x: HashMap<String, String>) -> Self
pub fn extra_http_headers(self, x: HashMap<String, String>) -> Self
An object containing additional HTTP headers to be sent with every request. All header values must be strings.
pub fn geolocation(self, x: Geolocation) -> Self
pub fn has_touch(self, x: bool) -> Self
Sourcepub fn http_credentials(self, x: &'i HttpCredentials) -> Self
pub fn http_credentials(self, x: &'i HttpCredentials) -> Self
Credentials for HTTP authentication.
Sourcepub fn ignore_https_errors(self, x: bool) -> Self
pub fn ignore_https_errors(self, x: bool) -> Self
Whether to ignore HTTPS errors during navigation. Defaults to false.
Sourcepub fn is_mobile(self, x: bool) -> Self
pub fn is_mobile(self, x: bool) -> Self
Whether the meta viewport tag is taken into account and touch events are enabled. Defaults to false. Not supported
in Firefox.
Sourcepub fn js_enabled(self, x: bool) -> Self
pub fn js_enabled(self, x: bool) -> Self
Whether or not to enable JavaScript in the context. Defaults to true.
Sourcepub fn locale(self, x: &'f str) -> Self
pub fn locale(self, x: &'f str) -> Self
Specify user locale, for example en-GB, de-DE, etc. Locale will affect navigator.language value, Accept-Language
request header value as well as number and date formatting rules.
Sourcepub fn no_viewport(self, x: bool) -> Self
pub fn no_viewport(self, x: bool) -> Self
Does not enforce fixed viewport, allows resizing window in the headed mode.
Sourcepub fn offline(self, x: bool) -> Self
pub fn offline(self, x: bool) -> Self
Whether to emulate network being offline. Defaults to false.
Sourcepub fn permissions(self, x: &'h [String]) -> Self
pub fn permissions(self, x: &'h [String]) -> Self
A list of permissions to grant to all pages in this context. See BrowserContext::grant_permissions for more details.
Sourcepub fn proxy(self, x: ProxySettings) -> Self
pub fn proxy(self, x: ProxySettings) -> Self
Network proxy settings to use with this context. Note that browser needs to be launched with the global proxy for this
option to work. If all contexts override the proxy, global proxy will be never used and can be any string, for example
launch({ proxy: { server: 'per-context' } }).
Sourcepub fn record_har(self, x: RecordHar<'k>) -> Self
pub fn record_har(self, x: RecordHar<'k>) -> Self
Enables HAR recording for all pages into recordHar.path file. If not
specified, the HAR is not recorded. Make sure to await [method: BrowserContext.close] for the HAR to be saved.
Sourcepub fn record_video(self, x: RecordVideo<'j>) -> Self
pub fn record_video(self, x: RecordVideo<'j>) -> Self
Enables video recording for all pages into recordVideo.dir directory. If not specified videos are not recorded. Make
sure to await [method: BrowserContext.close] for videos to be saved.
Sourcepub fn screen(self, x: Viewport) -> Self
pub fn screen(self, x: Viewport) -> Self
Emulates consistent window screen size available inside web page via window.screen. Is only used when the viewport
is set.
Sourcepub fn storage_state(self, x: StorageState) -> Self
pub fn storage_state(self, x: StorageState) -> Self
Populates context with given storage state. This option can be used to initialize context with logged-in information
obtained via [method: BrowserContext.storageState]. Either a path to the file with saved storage, or an object with
the following fields:
Sourcepub fn timezone_id(self, x: &'g str) -> Self
pub fn timezone_id(self, x: &'g str) -> Self
Changes the timezone of the context. See ICU’s metaZones.txt for a list of supported timezone IDs.
Sourcepub fn user_agent(self, x: &'e str) -> Self
pub fn user_agent(self, x: &'e str) -> Self
Specific user agent to use in this context.
Sourcepub fn viewport(self, x: Option<Viewport>) -> Self
pub fn viewport(self, x: Option<Viewport>) -> Self
Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. null disables the default viewport.