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

Error: ChromeMessage("Node is either not visible or not an HTMLElement") on a basic example #203

Open
JohnScience opened this issue Feb 3, 2024 · 2 comments

Comments

@JohnScience
Copy link

JohnScience commented Feb 3, 2024

I copy-pasted the example provided in the README:

use futures::StreamExt;

use chromiumoxide::browser::{Browser, BrowserConfig};

#[async_std::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // create a `Browser` that spawns a `chromium` process running with UI (`with_head()`, headless is default)
    // and the handler that drives the websocket etc.
    let (mut browser, mut handler) =
        Browser::launch(BrowserConfig::builder().with_head().build()?).await?;

    // spawn a new task that continuously polls the handler
    let handle = async_std::task::spawn(async move {
        while let Some(h) = handler.next().await {
            if h.is_err() {
                break;
            }
        }
    });

    // create a new browser page and navigate to the url
    let page = browser.new_page("https://en.wikipedia.org").await?;

    // find the search bar type into the search field and hit `Enter`,
    // this triggers a new navigation to the search result page
    page.find_element("#searchInput")
        .await?
        .click()
        .await?
        .type_str("Rust programming language")
        .await?
        .press_key("Enter")
        .await?;

    let html = page.wait_for_navigation().await?.content().await?;

    browser.close().await?;
    handle.await;
    Ok(())
}

A browser window with wikipedia opens but crashes almost instantly. This is the console output:

C:\Users\USER\Documents\github\booking-rooms\chromiumoxide-app>cargo run
   Compiling chromiumoxide-app v0.1.0 (C:\Users\USER\Documents\github\booking-rooms\chromiumoxide-app)
warning: unused variable: `html`
  --> src\main.rs:37:9
   |
37 |     let html = page.wait_for_navigation().await?.content().await?;
   |         ^^^^ help: if this is intentional, prefix it with an underscore: `_html`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: `chromiumoxide-app` (bin "chromiumoxide-app") generated 1 warning (run `cargo fix --bin "chromiumoxide-app"` to apply 1 suggestion)
    Finished dev [unoptimized + debuginfo] target(s) in 27.60s
     Running `target\debug\chromiumoxide-app.exe`
Error: ChromeMessage("Node is either not visible or not an HTMLElement")
error: process didn't exit successfully: `target\debug\chromiumoxide-app.exe` (exit code: 1)
@shulcsm
Copy link
Contributor

shulcsm commented Feb 5, 2024

Not a bug. Wikipedia changed their markup #searchInput is no longer a valid selector.

@Megaguirus
Copy link

the markup for the link used in the example doesn't contain the #searchInput ID for the input element. instead use https://www.wikipedia.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants