Skip to main content

SliderTab

Trait SliderTab 

Source
pub trait SliderTab {
    // Required methods
    fn sl_run_js(&self, js: &str) -> impl Future<Output = Result<Value>>;
    fn sl_ele_screenshot(
        &self,
        css_selector: &str,
    ) -> impl Future<Output = Result<Vec<u8>>>;
    fn sl_ele_click(&self, css_selector: &str) -> impl Future<Output = ()>;
    fn sl_mouse_move(&self, x: f64, y: f64) -> impl Future<Output = Result<()>>;
    fn sl_mouse_down(&self, x: f64, y: f64) -> impl Future<Output = Result<()>>;
    fn sl_mouse_drag(&self, x: f64, y: f64) -> impl Future<Output = Result<()>>;
    fn sl_mouse_drag_fast(&self, x: f64, y: f64) -> Result<()>;
    fn sl_mouse_up(&self, x: f64, y: f64) -> impl Future<Output = Result<()>>;
}
Available on crate feature slider only.
Expand description

滑块求解所需的后端原语(camoufox Tab 与 cdp ChromiumTab 都实现)。

核心求解逻辑(slider_gap/solve_slider 等)只依赖这几个原语,故与具体后端解耦; 想接入自定义后端,实现本 trait 即可复用整套滑块能力。定位器一律用 css:<sel> 前缀,方法内部 只传裸 CSS 选择器给 sl_ele_*,由实现自行补前缀。

Required Methods§

Source

fn sl_run_js(&self, js: &str) -> impl Future<Output = Result<Value>>

在页面里执行 JS 表达式并回传其值(缺口像素重活都在此)。

Source

fn sl_ele_screenshot( &self, css_selector: &str, ) -> impl Future<Output = Result<Vec<u8>>>

浏览器级截图某元素(CSS 选择器,taint-proof;顶象拼图跨域 taint 时用)。

Source

fn sl_ele_click(&self, css_selector: &str) -> impl Future<Output = ()>

best-effort 点击某元素(CSS 选择器;找不到则静默)。

Source

fn sl_mouse_move(&self, x: f64, y: f64) -> impl Future<Output = Result<()>>

鼠标移动到视口坐标。

Source

fn sl_mouse_down(&self, x: f64, y: f64) -> impl Future<Output = Result<()>>

鼠标按下(在视口坐标)。

Source

fn sl_mouse_drag(&self, x: f64, y: f64) -> impl Future<Output = Result<()>>

按住拖动到视口坐标(会等待往返,作节奏“屏障“)。

Source

fn sl_mouse_drag_fast(&self, x: f64, y: f64) -> Result<()>

按住拖动到视口坐标(同步、不等往返,主滑行密集 fire 用)。

Source

fn sl_mouse_up(&self, x: f64, y: f64) -> impl Future<Output = Result<()>>

鼠标松开(在视口坐标)。

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl SliderTab for ChromiumTab

Available on crate feature cdp only.
Source§

impl SliderTab for Tab

Available on crate feature camoufox only.