How to identify browser instance in devtools protocol

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

How to identify browser instance in devtools protocol

Postby fddima » Tue Jun 28, 2016 1:28 pm

Hello!

It is possible to somehow identify CEF browser instance with devtools protocol?
For example i'm create 3 browsers (let's assume that they have 1, 2, 3 identifiers).
Then i'm receive debugging endpoints by quering something like http://localhost:20480/json :

Code: Select all
[ {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:20480/devtools/page/58973311-D750-4EDE-AB04-09F0FDDB7872",
   "id": "58973311-D750-4EDE-AB04-09F0FDDB7872",
   "title": "Google",
   "type": "page",
   "url": "https://www.google.com.ua/?gfe_rd=cr&ei=U8ByV6CpPIOu8web3bSQAg&gws_rd=ssl",
   "webSocketDebuggerUrl": "ws://localhost:20480/devtools/page/58973311-D750-4EDE-AB04-09F0FDDB7872"
}, {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:20480/devtools/page/81F76E5A-499F-43B6-AF81-B0BF55F994C6",
   "id": "81F76E5A-499F-43B6-AF81-B0BF55F994C6",
   "title": "Google",
   "type": "page",
   "url": "https://www.google.com.ua/?gfe_rd=cr&ei=UsByV5OgOYOu8web3bSQAg&gws_rd=ssl",
   "webSocketDebuggerUrl": "ws://localhost:20480/devtools/page/81F76E5A-499F-43B6-AF81-B0BF55F994C6"
}, {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:20480/devtools/page/C060502C-0375-4D1C-A1BA-02D7BACA4694",
   "id": "C060502C-0375-4D1C-A1BA-02D7BACA4694",
   "title": "Google",
   "type": "page",
   "url": "https://www.google.com.ua/?gfe_rd=cr&ei=SMByV5OuFIOu8web3bSQAg&gws_rd=ssl",
   "webSocketDebuggerUrl": "ws://localhost:20480/devtools/page/C060502C-0375-4D1C-A1BA-02D7BACA4694"
} ]


And there is problem - we no have chance to identify browser instance with debugging endpoints (int vs guids).

Does someone already resolved this issue, or has any suggestions on it?
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: How to identify browser instance in devtools protocol

Postby fddima » Thu Jun 30, 2016 4:31 am

Well, personally i'm use trick: load page with very special unique URL, discover endpoint, attach debugger and then load target url.

But this will not work if we want attach debugger to existing page which is not prepared specially. It will be nice to have chance get DevTools host target id (string with GUID) without tricks (for API completeness).

PS: We don't interested in DevTools front-end so ShowDevTools is not a solution, we interested exactly in automated access to devtools debugging API and now obtain it via websocket url.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: How to identify browser instance in devtools protocol

Postby magreenblatt » Tue Jul 05, 2016 10:53 am

I presume you want to inspect multiple instances of the same URL? The GUIDs are randomly generated and aren't assigned until you visit the DevTools json URL for the first time.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How to identify browser instance in devtools protocol

Postby fddima » Tue Jul 05, 2016 10:34 pm

magreenblatt wrote:I presume you want to inspect multiple instances of the same URL? The GUIDs are randomly generated and aren't assigned until you visit the DevTools json URL for the first time.

Well, then special trick above have sense. It works well and acceptable.

i'm want inspect specific browser instance without rely to url or title. Actual url can be changed (page is navigated out). multiple pages can navigate out to same url, even they started from unique urls. Finally nothing prevent load same url in different instances for different purposes. So i'm choosing solutions which work stable as possible.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: How to identify browser instance in devtools protocol

Postby Anima » Mon Mar 11, 2019 7:42 am

Has anyone come across a better way of managing this relationship? I have a tab wrapper type class in my backend C# code and I'd like to keep a reference to some kind of websocket object in that wrapper. It's not very robust by just matching URLs and trying to keep track of the target IDs that way. I'd appreciate any input. Thanks.

Something a bit better (?) is maybe writing a CEF extension in JS to inject some data and retrieve this later via the DevTools protocol to find out which tab a certain TargetID is referring to.
Anima
Newbie
 
Posts: 8
Joined: Wed Aug 02, 2017 9:06 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 115 guests