mattsse / chromiumoxide

Chrome Devtools Protocol rust API
Apache License 2.0
755 stars 78 forks source link

Does it support Chinese? #216

Open SnailFighter opened 5 months ago

SnailFighter commented 5 months ago

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 RunningE:\rust\chromium\ticket_robber\target\debug\ticket_robber.exe 11111111111111111111111the 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)

TinusgragLin commented 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.

TinusgragLin commented 5 months ago

If you are looking for a crate for browser automation, thirtyfour is a popular option.

SnailFighter commented 5 months ago

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.

TinusgragLin commented 5 months ago

Note that if the experimental Input.insertText command is stabilized and implemented, this unfortunate limitation will be lifted.

SnailFighter commented 5 months ago

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.

openmynet commented 5 days ago

///  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(())
}