use std::collections::HashMap;
use crate::cdp::client::CdpClient;
use crate::element_ref::ElementRef;
pub async fn run(
client: &CdpClient,
uid_map: &HashMap<String, ElementRef>,
uid: &str,
value: &str,
) -> Result<(String, crate::element::FillOutcome), crate::BoxError> {
let outcome = crate::element::fill(client, uid_map, uid, value).await?;
Ok((format!("Filled uid={uid} with {}", value.len()), outcome))
}
pub async fn run_form(
client: &CdpClient,
uid_map: &HashMap<String, ElementRef>,
pairs: &[(&str, &str)],
) -> Result<(String, Vec<(String, crate::element::FillOutcome)>), crate::BoxError> {
let mut outcomes = Vec::new();
for (uid, value) in pairs {
let outcome = crate::element::fill(client, uid_map, uid, value).await?;
outcomes.push(((*uid).to_string(), outcome));
}
let names: Vec<String> = outcomes.iter().map(|(uid, _)| format!("uid={uid}")).collect();
Ok((format!("Filled {} fields: {}", names.len(), names.join(", ")), outcomes))
}