ContextBuilder

Struct ContextBuilder 

Source
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>

Source

pub async fn build(self) -> Result<BrowserContext, Arc<Error>>

Source

fn new(inner: Weak<Browser>) -> Self

Source

pub fn set_device(self, device: &'e DeviceDescriptor) -> Self

Source

pub fn accept_downloads(self, x: bool) -> Self

Whether to automatically download all the attachments. Defaults to false where all the downloads are canceled.

Source

pub fn bypass_csp(self, x: bool) -> Self

Toggles bypassing page’s Content-Security-Policy.

Source

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'.

Source

pub fn device_scale_factor(self, x: f64) -> Self

Specify device scale factor (can be thought of as dpr). Defaults to 1.

Source

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.

Source

pub fn geolocation(self, x: Geolocation) -> Self

Source

pub fn has_touch(self, x: bool) -> Self

Source

pub fn http_credentials(self, x: &'i HttpCredentials) -> Self

Credentials for HTTP authentication.

Source

pub fn ignore_https_errors(self, x: bool) -> Self

Whether to ignore HTTPS errors during navigation. Defaults to false.

Source

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.

Source

pub fn js_enabled(self, x: bool) -> Self

Whether or not to enable JavaScript in the context. Defaults to true.

Source

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.

Source

pub fn no_viewport(self, x: bool) -> Self

Does not enforce fixed viewport, allows resizing window in the headed mode.

Source

pub fn offline(self, x: bool) -> Self

Whether to emulate network being offline. Defaults to false.

Source

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.

Source

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' } }).

Source

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.

Source

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.

Source

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.

Source

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:

Source

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.

Source

pub fn user_agent(self, x: &'e str) -> Self

Specific user agent to use in this context.

Source

pub fn viewport(self, x: Option<Viewport>) -> Self

Emulates consistent viewport for each page. Defaults to an 1280x720 viewport. null disables the default viewport.

Source

pub fn clear_accept_downloads(self) -> Self

Source

pub fn clear_bypass_csp(self) -> Self

Source

pub fn clear_color_scheme(self) -> Self

Source

pub fn clear_device_scale_factor(self) -> Self

Source

pub fn clear_extra_http_headers(self) -> Self

Source

pub fn clear_geolocation(self) -> Self

Source

pub fn clear_has_touch(self) -> Self

Source

pub fn clear_http_credentials(self) -> Self

Source

pub fn clear_ignore_https_errors(self) -> Self

Source

pub fn clear_is_mobile(self) -> Self

Source

pub fn clear_js_enabled(self) -> Self

Source

pub fn clear_locale(self) -> Self

Source

pub fn clear_no_viewport(self) -> Self

Source

pub fn clear_offline(self) -> Self

Source

pub fn clear_permissions(self) -> Self

Source

pub fn clear_proxy(self) -> Self

Source

pub fn clear_record_har(self) -> Self

Source

pub fn clear_record_video(self) -> Self

Source

pub fn clear_screen(self) -> Self

Source

pub fn clear_storage_state(self) -> Self

Source

pub fn clear_timezone_id(self) -> Self

Source

pub fn clear_user_agent(self) -> Self

Source

pub fn clear_viewport(self) -> Self

Auto Trait Implementations§

§

impl<'e, 'f, 'g, 'h, 'i, 'j, 'k> Freeze for ContextBuilder<'e, 'f, 'g, 'h, 'i, 'j, 'k>

§

impl<'e, 'f, 'g, 'h, 'i, 'j, 'k> RefUnwindSafe for ContextBuilder<'e, 'f, 'g, 'h, 'i, 'j, 'k>

§

impl<'e, 'f, 'g, 'h, 'i, 'j, 'k> Send for ContextBuilder<'e, 'f, 'g, 'h, 'i, 'j, 'k>

§

impl<'e, 'f, 'g, 'h, 'i, 'j, 'k> Sync for ContextBuilder<'e, 'f, 'g, 'h, 'i, 'j, 'k>

§

impl<'e, 'f, 'g, 'h, 'i, 'j, 'k> Unpin for ContextBuilder<'e, 'f, 'g, 'h, 'i, 'j, 'k>

§

impl<'e, 'f, 'g, 'h, 'i, 'j, 'k> UnwindSafe for ContextBuilder<'e, 'f, 'g, 'h, 'i, 'j, 'k>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.