How to close a tab through chrome dev tools protocol?

4,011 views
Skip to first unread message

Oren Bilgoray

unread,
Jul 12, 2014, 6:01:09 AM7/12/14
to google-chrome-...@googlegroups.com
How can I close a tab through chrome dev tools protocol?

I'm using chrome dev tools for android.

PhistucK

unread,
Jul 12, 2014, 1:55:08 PM7/12/14
to Google Chrome Developer Tools
The Developer Tools protocol is not meant for controlling the browser, but only for controlling the page, so I do not think there is an explicit way to do it.
As far as workarounds go, you can try evaluating window.close(); or adding a function that calls the same function as a click event listener and use the screencasting feature for clicking on the element to which you added that click event listener.


PhistucK


On Sat, Jul 12, 2014 at 1:01 PM, Oren Bilgoray <bil...@gmail.com> wrote:
How can I close a tab through chrome dev tools protocol?

I'm using chrome dev tools for android.

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/553f2226-113a-4115-ac32-837f50fcbec4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pavel Feldman

unread,
Jul 12, 2014, 1:58:12 PM7/12/14
to Google Chrome Developer Tools

How do you connect over remote debugging protocol?

Oren Bilgoray

unread,
Jul 17, 2014, 3:04:28 PM7/17/14
to google-chrome-...@googlegroups.com
Do you know what the "close" page in the web inspector doing?


On Saturday, July 12, 2014 8:58:12 PM UTC+3, pfeldman wrote:

How do you connect over remote debugging protocol?

On Jul 12, 2014 9:55 PM, "PhistucK" <phis...@gmail.com> wrote:
The Developer Tools protocol is not meant for controlling the browser, but only for controlling the page, so I do not think there is an explicit way to do it.
As far as workarounds go, you can try evaluating window.close(); or adding a function that calls the same function as a click event listener and use the screencasting feature for clicking on the element to which you added that click event listener.


PhistucK


On Sat, Jul 12, 2014 at 1:01 PM, Oren Bilgoray <bil...@gmail.com> wrote:
How can I close a tab through chrome dev tools protocol?

I'm using chrome dev tools for android.

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Google Chrome Developer Tools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-developer-tools+unsub...@googlegroups.com.

Pavel Feldman

unread,
Jul 18, 2014, 12:15:04 PM7/18/14
to Google Chrome Developer Tools
On Thu, Jul 17, 2014 at 11:04 PM, Oren Bilgoray <bil...@gmail.com> wrote:
Do you know what the "close" page in the web inspector doing?

"close" page?
 


On Saturday, July 12, 2014 8:58:12 PM UTC+3, pfeldman wrote:

How do you connect over remote debugging protocol?


Depending on how your remote debugging session is initiated, you might be able to automate chrome and close the page. But I need to know how you are doing it to help further.
 
To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/06debf13-3d15-4f9c-aa2f-d10d316afc77%40googlegroups.com.

Oren Bilgoray

unread,
Jul 19, 2014, 7:26:13 AM7/19/14
to google-chrome-...@googlegroups.com
I mean this close page (attached screenshot).

I'm using javascript to get the pages and opening a websocket to the desired page.

I want to know if I can close a page somehow...
discoverusb.png

Pavel Feldman

unread,
Jul 19, 2014, 9:14:29 AM7/19/14
to Google Chrome Developer Tools

It issues http get at /json/close/<target_guid>

To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/d0bf1f5b-1195-4a4e-a24b-ca850623e941%40googlegroups.com.

Oren Bilgoray

unread,
Jul 19, 2014, 9:28:53 AM7/19/14
to google-chrome-...@googlegroups.com
Thx. This is what I wanted.

Now I need to find how can I get the number of the front page.

Pavel Feldman

unread,
Jul 19, 2014, 9:44:00 AM7/19/14
to Google Chrome Developer Tools

I don't think you can. You could try using chrome.tabs extensions api for automation instead - it would give you more options.

Pavel

To unsubscribe from this group and stop receiving emails from it, send an email to google-chrome-develo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-chrome-developer-tools/cb146ee6-cd95-4e79-b581-458896f859c1%40googlegroups.com.

Oren Bilgoray

unread,
Jul 19, 2014, 10:03:15 AM7/19/14
to google-chrome-...@googlegroups.com, pfel...@google.com
chrome.tabs extension api works also for Android chrome?

Pavel Feldman

unread,
Jul 19, 2014, 10:17:57 AM7/19/14
to Oren Bilgoray, Google Chrome Developer Tools

No. But in Chrome for Android tabs are (currently) sorted by last access time, so the first one is topmost.

Pavel

mi...@bocoup.com

unread,
Mar 1, 2019, 9:40:44 AM3/1/19
to Chrome DevTools
This is an old thread, but it still ranks in search engine results.
Here's what I've found in February 2019.

Executing a script with `window.close` probably requires `userGesture`
parameter of `Page.evaluate` [1]. That's just speculation, though; I
couldn't get it to work personally.

The "tip-of-tree" protocol now defines a `Target` domain which includes
`Target.closeTarget` [2]. That seems like the expected way to achieve
this.

For folks who can't use that version, Chromium exposes an endpoint on
its REST endpoint, `GET /json/close/{targetId}` [3]. I don't know if
this is technically part of CDP, but it's what ChromeDriver is using
currently.

Reply all
Reply to author
Forward
0 new messages