Skip to content

Commit

Permalink
feat(page): add override geolocation emulation
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mendez committed Dec 29, 2023
1 parent b335d30 commit df7e653
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use futures::{stream, SinkExt, StreamExt};

use chromiumoxide_cdp::cdp::browser_protocol::dom::*;
use chromiumoxide_cdp::cdp::browser_protocol::emulation::{
MediaFeature, SetEmulatedMediaParams, SetTimezoneOverrideParams, SetLocaleOverrideParams,
MediaFeature, SetEmulatedMediaParams, SetTimezoneOverrideParams,
SetLocaleOverrideParams, SetGeolocationOverrideParams,
};
use chromiumoxide_cdp::cdp::browser_protocol::network::{
Cookie, CookieParam, DeleteCookiesParams, GetCookiesParams, SetCookiesParams,
Expand Down Expand Up @@ -640,6 +641,15 @@ impl Page {
Ok(self)
}

/// Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.
pub async fn emulate_geolocation(
&self,
geolocation: impl Into<SetGeolocationOverrideParams>,
) -> Result<&Self> {
self.execute(geolocation.into()).await?;
Ok(self)
}

/// Reloads given page
///
/// To reload ignoring cache run:
Expand Down

0 comments on commit df7e653

Please sign in to comment.