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

enable_request_intercept() with page.goto() #231

Open
EpixMan opened this issue Aug 4, 2024 · 0 comments
Open

enable_request_intercept() with page.goto() #231

EpixMan opened this issue Aug 4, 2024 · 0 comments

Comments

@EpixMan
Copy link

EpixMan commented Aug 4, 2024

I am new to chromiumoxide so please tell me if I did something wrong.

EDIT: I did some experimentation and found that the problem is not with "page:blank", but rather with page.goto()

Upon experiencing how chromiumoxide works, I tried to modify the file in https://github.com/mattsse/chromiumoxide/blob/main/examples/interception.rs which creates a new page with "about:blank", for some reason, page.goto would do nothing then gives Timeout error.

I think it would be simpler to show the code:
`use std::sync::Arc;
use std::time::Duration;
use futures::StreamExt;

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

#[async_std::main]
async fn main() -> Result<(), Box> {
tracing_subscriber::fmt::init();

let (mut browser, mut handler) = Browser::launch(
    //notice how removing  enable_request_intercept() would make it works
    BrowserConfig::builder().enable_request_intercept().request_timeout(Duration::from_secs(10))
        .disable_cache()
        .build()?,
)
    .await?;

let browser_handle = async_std::task::spawn(async move {
    while let Some(h) = handler.next().await {
        if h.is_err() {
            break;
        }
    }
});
//This is working
//let page = Arc::new(browser.new_page("https://wikipedia.org/").await?);
//page.wait_for_navigation().await?;
//page.find_element("input#searchInput")
//    .await?
//    .click()
//    .await?
//    .type_str("Rust programming language")
//    .await?
//    .press_key("Enter")
//    .await?;

//This does not, it would just time out. But removing enable_request_intercept() would make it works
let page = Arc::new(browser.new_page("about:blank").await?);
page.goto("https://wikipedia.org/").await?;

page.wait_for_navigation().await?;

println!("{:?}", page.content().await?);

browser.close().await?;
browser_handle.await;

Ok(())

}

`

@EpixMan EpixMan changed the title enable_request_intercept() with "about:blank" as the new page would cause timeout enable_request_intercept() with page.goto() Aug 4, 2024
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

1 participant