You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
I copy-pasted the example provided in the README:
A browser window with wikipedia opens but crashes almost instantly. This is the console output:
The text was updated successfully, but these errors were encountered: