pub struct InteractionSimulator { /* private fields */ }Expand description
Simulates random human-like page interactions.
Combines scroll patterns, mouse micro-movements, and reading pauses to
produce convincing human browsing behaviour. The intensity is controlled
by InteractionLevel.
§Example
use stygian_browser::behavior::{InteractionSimulator, InteractionLevel};
let mut sim = InteractionSimulator::new(InteractionLevel::Medium);
sim.random_interaction(page, 1280.0, 800.0).await?;Implementations§
Source§impl InteractionSimulator
impl InteractionSimulator
Sourcepub fn new(level: InteractionLevel) -> Self
pub fn new(level: InteractionLevel) -> Self
Create a new interaction simulator with the given interaction level.
§Example
use stygian_browser::behavior::{InteractionSimulator, InteractionLevel};
let sim = InteractionSimulator::new(InteractionLevel::Low);Sourcepub const fn with_seed(seed: u64, level: InteractionLevel) -> Self
pub const fn with_seed(seed: u64, level: InteractionLevel) -> Self
Create a simulator with a fixed seed (useful for unit-testing).
§Example
use stygian_browser::behavior::{InteractionSimulator, InteractionLevel};
let sim = InteractionSimulator::with_seed(42, InteractionLevel::High);Sourcepub async fn random_interaction(
&mut self,
page: &Page,
viewport_w: f64,
viewport_h: f64,
) -> Result<()>
pub async fn random_interaction( &mut self, page: &Page, viewport_w: f64, viewport_h: f64, ) -> Result<()>
Perform a random human-like interaction matching the configured level.
| Level | Actions |
|---|---|
None | No-op |
Low | One scroll + short pause (500–1 500 ms) |
Medium | Scroll + mouse wiggle + reading pause (1–3 s) |
High | Medium + second wiggle + optional scroll-back |
§Parameters
page— The active browser page.viewport_w/viewport_h— Approximate viewport size in CSS pixels.
§Errors
Returns BrowserError::CdpError if any CDP call fails.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for InteractionSimulator
impl RefUnwindSafe for InteractionSimulator
impl Send for InteractionSimulator
impl Sync for InteractionSimulator
impl Unpin for InteractionSimulator
impl UnwindSafe for InteractionSimulator
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