If I connect() to an existing Chromium instance with one or more already open tabs, calling browser.pages() returns an empty vector instead of listing the open tabs which are visible via CDP at http://localhost:9222/json.
I don't know if this is intended behaviour but it somewhat negates the usefulness of connecting to an existing instance I believe.
It can be reproduced as so:
Launch chrome with remote debugging enabled, for example:
let url = "ws://localhost:9222/devtools/browser/{some id}";
// browser/handler
let (mut browser, mut handler) = Browser::connect(url).await.unwrap();
// spawn a new task that continuously polls the handler
let handle = tokio::task::spawn(async move {
while let Some(h) = handler.next().await {
if h.is_err() {
break;
}
}
});
// list pages
let pages = browser.pages().await;
let pages = pages.unwrap_or_default();
println!("{:?}", pages);
// --> an empty vec
let page = browser.new_page("https://example.com").await;
let pages = browser.pages().await;
let pages = pages.unwrap_or_default();
println!("{:?}", pages);
// --> a vec containing the example.com page
If I
connect()
to an existing Chromium instance with one or more already open tabs, callingbrowser.pages()
returns an empty vector instead of listing the open tabs which are visible via CDP athttp://localhost:9222/json
.I don't know if this is intended behaviour but it somewhat negates the usefulness of connecting to an existing instance I believe.
It can be reproduced as so:
Launch chrome with remote debugging enabled, for example:
$ google-chrome-stable --remote-debugging-port=9222
Connect and list the pages: