Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash at get_midpoint #364

Closed
makorne opened this issue Feb 2, 2023 · 3 comments · Fixed by #396
Closed

Crash at get_midpoint #364

makorne opened this issue Feb 2, 2023 · 3 comments · Fixed by #396
Labels
bug Something isn't working

Comments

@makorne
Copy link

makorne commented Feb 2, 2023

Hi!
Thank you for great crate!

After several successful click at the same button, something changed on page and:

thread 'main' panicked at 'calledOption::unwrap()on aNonevalue', /home/den/.cargo/git/checkouts/rust-headless-chrome-fd32a97e7a7fa8b4/60b775b/src/browser/tab/element/mod.rs:510:51

let raw_quad = quad.quads.first().unwrap(); << this unwrap

Buttons div changed to <div style="display: none;">

@masc-it
Copy link
Contributor

masc-it commented Feb 7, 2023

Hi @makorne, are you using CSS or XPATH selector to find such button?

@makorne
Copy link
Author

makorne commented Feb 7, 2023

Hi @masc-it

while let Ok(button) = tab.wait_for_element(".button1"){ 
    match button.click() {
     ...
    }
}

@Ratipoka
Copy link
Contributor

Ratipoka commented Jun 18, 2023

I had the same issue trying to click on a button

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', C:\Users\me\.cargo\registry\src\github.com-1ecc6299db9ec823\headless_chrome-1.0.5\src\browser\tab\element\mod.rs:510:51

Looking in the code, the line @makorne pointed :
let raw_quad = quad.quads.first().unwrap();
suggests that the quad array returned by the GetContentQuad method was empty
Looking in some DOM docs (and asking chatgpt) it could be that this happens if the element we are trying to click is not visible.

I've checked with headless(false) what could be blocking the view of the button and it turns out that it was hidden behind a cookie popup.

adding

tab.wait_for_xpath(r#"//*[@id="bnp_btn_reject"]"#)?
    .click()?;

fixed the issue for me.

Maybe we could change the code to something like this :

let raw_quad = quad.quads.first().except("tried to get the midpoint of an element which is not visible");

to get a more helpfull error than

'called `Option::unwrap()` on a `None` value'

@mdrokz mdrokz linked a pull request Aug 9, 2023 that will close this issue
@mdrokz mdrokz added the bug Something isn't working label Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants