mattsse / chromiumoxide

Chrome Devtools Protocol rust API
Apache License 2.0
787 stars 81 forks source link

find_element and CSS selector #93

Open yassinevic opened 2 years ago

yassinevic commented 2 years ago

Hello

I just start playing with this tool. But i can't get any selector to work beside [name='j_username']

th code bellow will faile with error "-32000: DOM Error while querying" same thing for [id='j_username']

did i miss somthing?

let page = browser.new_page("https://www.google.com/").await?; std::thread::sleep(std::time::Duration::from_secs(3)); page.find_element("a[href=https://policies.google.com/privacy?hl=en-MA&fg=1]").await? .click() .await?;

Tnx

escritorio-gustavo commented 1 year ago

Try wrapping the attribute value in double quotes

let page = browser.new_page("https://www.google.com/").await?;
std::thread::sleep(std::time::Duration::from_secs(3));
page
    .find_element(r#"a[href="https://policies.google.com/privacy?hl=en-MA&fg=1"]"#)
    .await?
    .click()
    .await?;