Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(page): add override geolocation emulation #199

Merged
merged 2 commits into from
Dec 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading