Open SnailFighter opened 5 months ago
type_str(str)
send a series of dispatchKeyEvent
command messages to chromium via Chrome DevTools Protocol (on which this project is based) to emulate a series of keyboard input events. Since there is no “你” key in the standard keyboard, this error is expected.
If you are looking for a crate for browser automation, thirtyfour is a popular option.
If you are looking for a crate for browser automation, thirtyfour is a popular option.
Ok, thanks for your advice, let me try the crate.
Note that if the experimental Input.insertText
command is stabilized and implemented, this unfortunate limitation will be lifted.
If you are looking for a crate for browser automation, thirtyfour is a popular option.
get, if so, just only can input english, at present.
/// input(page, &element, "你好")
pub async fn input_text(page: &Page, element: &Element, text: &str) -> Result<()> {
element.click().await?;
let cmd = chromiumoxide::cdp::browser_protocol::input::InsertTextParams::new(text);
page.execute(cmd).await?;
Ok(())
}
I try to type_str(Chinese words), but it fails, now doesn't it support Chinese?
let search_list_page = search_element.type_str("你好").await?.press_key("Enter").await?;
and
Finished dev [unoptimized + debuginfo] target(s) in 0.17s Running
E:\rust\chromium\ticket_robber\target\debug\ticket_robber.exe11111111111111111111111the input-search element Element { remote_object_id: RemoteObjectId("1726069268081028633.3.3"), backend_node_id: BackendNodeId(14), node_id: NodeId(53), tab: PageInner { target_id: TargetId("62E07B0F3A85FD64F6912AEEB60FFA8A"), session_id: SessionId("1D060927DF75427396A695CC3468E1FA"), sender: Sender { closed: false } } } Error: ChromeMessage("Key not found: 你") error: process didn't exit successfully:
E:\rust\chromium\ticket_robber\target\debug\ticket_robber.exe(exit code: 1)