Comments (6)
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.
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.
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.
Yeah, that seems like a great first step. There are a couple options that I can see
- 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.
- 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.
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.
@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)
- Is there a example to take response body from request network?
- Is there an example of Network Request Interception? HOT 2
- Is there a way to force the browser to close in case the rust process is closed?
- How to wait for a specific dynamically loaded element to load?
- `<iframe>` elements stop page from loading HOT 28
- How to update .pdl files
- Critical Deserialization issue HOT 18
- CommandFuture will be polled forever if Page is closed.
- Unable to configure timeout on commands HOT 3
- Times Out On Any Website Using <browser>.new_page() HOT 9
- How'd i use proxy while taking screenshots HOT 1
- proxy arg not working
- Use new headless mode. HOT 1
- `page.wait_for_navigation().await?;` seems to return before all the pages assets (images,js,css) are fully loaded HOT 4
- Error `unknown flag 'disable-background-networking'` while using with Chromium HOT 1
- Page.goto hangs on some websites while browser.new_page works
- Is there a way to get access to the `redirect_chain` ?
- Error: ChromeMessage("Node is either not visible or not an HTMLElement") on a basic example HOT 2
- Running an init script
- Random crashes when not using headless mode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chromiumoxide.