Skip to content

Commit

Permalink
feat(page): add override geolocation emulation (#199)
Browse files Browse the repository at this point in the history
* feat(page): add override geolocation emulation

* chore(fmt): fix format timezone
  • Loading branch information
j-mendez authored Dec 30, 2023
1 parent b335d30 commit 8d039e5
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, SetGeolocationOverrideParams, SetLocaleOverrideParams,
SetTimezoneOverrideParams,
};
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 8d039e5

Please sign in to comment.