pub struct EmulationController { /* private fields */ }Expand description
Controller that exposes Emulation domain commands for a page.
Implementations§
Source§impl EmulationController
impl EmulationController
Sourcepub async fn apply_config(&self, config: &EmulationConfig) -> Result<()>
pub async fn apply_config(&self, config: &EmulationConfig) -> Result<()>
Applies a collection of emulation overrides to the target page.
§Examples
let geolocation = Geolocation::new(37.7749, -122.4194).with_accuracy(1.0);
let config = EmulationConfig::default().with_geolocation(geolocation);
page.emulation().apply_config(&config).await?;Sourcepub async fn set_geolocation(&self, geolocation: Geolocation) -> Result<()>
pub async fn set_geolocation(&self, geolocation: Geolocation) -> Result<()>
Overrides the page’s geolocation values until cleared.
Sourcepub async fn clear_geolocation(&self) -> Result<()>
pub async fn clear_geolocation(&self) -> Result<()>
Removes any geolocation override previously applied.
Sourcepub async fn set_timezone<T: Into<String>>(&self, timezone_id: T) -> Result<()>
pub async fn set_timezone<T: Into<String>>(&self, timezone_id: T) -> Result<()>
Sets the emulated timezone identifier (IANA format).
Sourcepub async fn reset_timezone(&self) -> Result<()>
pub async fn reset_timezone(&self) -> Result<()>
Resets the timezone override to the browser default.
Sourcepub async fn set_locale(&self, locale: Option<&str>) -> Result<()>
pub async fn set_locale(&self, locale: Option<&str>) -> Result<()>
Overrides the page locale (for example “en-US”).
Sourcepub async fn set_media(&self, media: MediaEmulation) -> Result<()>
pub async fn set_media(&self, media: MediaEmulation) -> Result<()>
Applies media emulation settings, such as prefers-color-scheme.
Sourcepub async fn clear_media(&self) -> Result<()>
pub async fn clear_media(&self) -> Result<()>
Clears any previously applied media emulation overrides.
Sourcepub async fn set_user_agent(
&self,
override_data: UserAgentOverride,
) -> Result<()>
pub async fn set_user_agent( &self, override_data: UserAgentOverride, ) -> Result<()>
Overrides the user agent string and optional metadata.
Auto Trait Implementations§
impl Freeze for EmulationController
impl !RefUnwindSafe for EmulationController
impl Send for EmulationController
impl Sync for EmulationController
impl Unpin for EmulationController
impl !UnwindSafe for EmulationController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more