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

Please help, can't run chrome browser #269

Open
CarbonPool opened this issue Aug 13, 2024 · 2 comments
Open

Please help, can't run chrome browser #269

CarbonPool opened this issue Aug 13, 2024 · 2 comments

Comments

@CarbonPool
Copy link

CarbonPool commented Aug 13, 2024

I downloaded the corresponding version of chromedriver and ran this command
.\chromedriver.exe --port=4444

Refer to the example, my code is as follows, but there is no startup response.

use fantoccini::{ClientBuilder, Locator};
fn main() {
    start();
}

async fn start() {
    let c = ClientBuilder::native().connect("http://localhost:4444").await.expect("failed to connect to WebDriver");
    c.goto("https://www.google.com").await.unwrap();
}
@jonhoo
Copy link
Owner

jonhoo commented Aug 18, 2024

It's impossible to debug this without information about what errors you got and what else actually happened. Could you include some information about the output you've gotten as well?

@rustworthy
Copy link

Hi there!

@CarbonPool If this is token for token what you are running, one thing is missing: we will need a runtime (like tokio) to drive the future returned by start() to completion.

So if we block on the future in the main, there should be a startup response. Alternatively, we could await with start().await, but then the fn main should be turned to async fn main with the tokio::main attribute on it (which creates a runtime and a blocks on the given future for us).

use fantoccini::ClientBuilder;

#[tokio::main]
async fn main() {
    start().await;
}

async fn start() {
    let c = ClientBuilder::native()
        .connect("http://localhost:4444")
        .await
        .expect("failed to connect to WebDriver");
    c.goto("https://www.google.com").await.unwrap();
}

The tokio::main is behind rt and macros features, so it should be accounted for in the project's Cargo.toml:

[dependencies]
fantoccini = "0.21.4"
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread"] }

Hopefully, that helps

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