use serde_json::Value;
use super::ChromiumTab;
use crate::Result;
use crate::slider::{SliderConfig, SliderGap, SliderResult, SliderTab};
impl SliderTab for ChromiumTab {
fn sl_run_js(&self, js: &str) -> impl std::future::Future<Output = Result<Value>> {
self.run_js(js)
}
async fn sl_ele_screenshot(&self, css_selector: &str) -> Result<Vec<u8>> {
self.ele(&format!("css:{css_selector}"))
.await?
.screenshot_bytes()
.await
}
async fn sl_ele_click(&self, css_selector: &str) {
if let Ok(e) = self.ele(&format!("css:{css_selector}")).await {
let _ = e.click().await;
}
}
fn sl_mouse_move(&self, x: f64, y: f64) -> impl std::future::Future<Output = Result<()>> {
self.mouse_move(x, y)
}
fn sl_mouse_down(&self, x: f64, y: f64) -> impl std::future::Future<Output = Result<()>> {
self.mouse_down(x, y)
}
fn sl_mouse_drag(&self, x: f64, y: f64) -> impl std::future::Future<Output = Result<()>> {
self.mouse_drag(x, y)
}
fn sl_mouse_drag_fast(&self, x: f64, y: f64) -> Result<()> {
self.mouse_drag_fast(x, y)
}
fn sl_mouse_up(&self, x: f64, y: f64) -> impl std::future::Future<Output = Result<()>> {
self.mouse_up(x, y)
}
}
impl ChromiumTab {
pub async fn slider_gap(&self, cfg: &SliderConfig) -> Result<SliderGap> {
crate::slider::slider_gap(self, cfg).await
}
pub async fn solve_slider(&self, cfg: &SliderConfig) -> Result<SliderResult> {
crate::slider::solve_slider(self, cfg).await
}
pub async fn geetest_slide_gap(&self) -> Result<SliderGap> {
crate::slider::geetest_slide_gap(self).await
}
pub async fn solve_geetest_slide(&self) -> Result<SliderResult> {
crate::slider::solve_geetest_slide(self).await
}
pub async fn dingxiang_slide_gap(&self, index: u32) -> Result<SliderGap> {
crate::slider::dingxiang_slide_gap(self, index).await
}
pub async fn solve_dingxiang_slide(
&self,
index: u32,
open: Option<&str>,
) -> Result<SliderResult> {
crate::slider::solve_dingxiang_slide(self, index, open).await
}
}