Giter Club home page Giter Club logo

Comments (6)

clarkmcc avatar clarkmcc commented on June 12, 2024

I'm running into the same issue using the exact code here https://github.com/mattsse/chromiumoxide/blob/main/examples/wiki-tokio.rs. My Cargo.toml matches the README. Any updates on this?

chromiumoxide = { git = "https://github.com/mattsse/chromiumoxide", features = ["tokio-runtime"], default-features = false, branch = "main"}

from chromiumoxide.

clarkmcc avatar clarkmcc commented on June 12, 2024

After some experimentation, based on this problem and solution, it looks like this library cannot handle Chrome using an existing browser session due to a known issue in Chrome. In other words, if you have a Chrome window open already, the Chrome binary that is started by chromiumoxide will use the existing browser session, but it will not know how to bootstrap itself into that browser session because the command does not return the web socket URL.

The workaround (which seems perfectly reasonable to me) is to specify a user data directory which forces Chrome to use create a new browser session:

BrowserConfig::builder().user_data_dir("/tmp").build()

from chromiumoxide.

mattsse avatar mattsse commented on June 12, 2024

thanks for digging into this!
I guess there is no easy way to detect this ourself, so we need to make note of this somewhere, maybe add a note in the known issues section?

from chromiumoxide.

clarkmcc avatar clarkmcc commented on June 12, 2024

Yeah, that seems like a great first step. There are a couple options that I can see

  1. We dig into chrome a bit more and see how to get the ws URL for an existing browser session. That would solve the problem, but it means that we run everything within the context of a user's browser; that means user's passwords, user's history, etc. It seems like you'd rarely want to do this, so I feel like this should be explicit behavior.
  2. We do something like what chromedp does and create our own temporary user-data-dirs in the system tmp folder every time we run. This guarantees a fresh instance of the browser. https://github.com/chromedp/chromedp/blob/ded6f35d3264c00fcfb622d3e06514fafd82bf46/allocate.go#L142-L151

I personally like option two better, especially since it will be familiar to users of chromedp (and likely puppeteer). I'd be happy to create a PR if that would be helpful.

from chromiumoxide.

mattsse avatar mattsse commented on June 12, 2024

seems like option 1 has some drawbacks

option 2 sounds great, even though it requires some temp data.
happy to approve a PR for that :)
I feel like attaching a tempdir handle to the browser config or something could do the trick

from chromiumoxide.

clarkmcc avatar clarkmcc commented on June 12, 2024

@mattsse I think I took a slightly different approach than what you were going for so feel free to point me in the right direction. I'm fairly new to Rust.

from chromiumoxide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.