CDP.Close() not working with Chrome 59 on macOS
See original GitHub issueHi, I’m trying to do the following actions:
- open a new (headless) Chrome tab
- navigate to an URL
- take e screenshot
- close Tab
And closing tab doesn’t work. In fact, if I do a http://localhost:9222/json/list all the tabs opened at specified pages are listed.
Basically, the code is the following:
...
const target = await CDP.New({ port: this.options.port || 9222 });
const tab = await CDP({ target });
const tabId = tab.target.id;
const { Page, Emulation } = tab;
await Promise.all([
Page.enable(),
Emulation.setDeviceMetricsOverride(options.metrics),
Emulation.setVisibleSize({ width: options.metrics.width, height: options.metrics.height }),
Emulation.forceViewport({ x: 0, y: 0, scale: 1 }),
]);
await Page.navigate({ url: url });
await Page.loadEventFired();
let { data } = await Page.captureScreenshot({ format: 'png', fromSurface: true });
// do something with data...
// close tab
await CDP.Close( {id: tabId});
I’ve also tried using Runtime:
await tab.Runtime.evaluate({expression: 'window.close();'})
but again, tabs stay open. Many thanks.
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Google Chrome won't shut down on Mac? Try these fixes
We've got all the troubleshooting answers for what to do when Chrome won't shut down on your Mac. From Terminal commands to Chrome...
Read more >Getting Started with Headless Chrome - Chrome Developers
It's a way to run the Chrome browser in a headless environment. Essentially, running Chrome without chrome! It brings all modern web platform ......
Read more >How to install and use Headless Chrome on OSX
This walkthrough shows you how to get headless Chrome up and running on OSX and explains in detail how to use the code...
Read more >chrome-remote-interface - npm
The solution is to provide an up-to-date one, or if you are using the protocol embedded in chrome-remote-interface, make sure to be running...
Read more >Fix Chrome update problems & failed updates - Google Support
If you're having problems updating Chrome on your computer, you might see: Update failed: Updates are disabled by administrator Update failed (Error: 3...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah, that makes sense. I’ve opened a PR that adds a general note. Feel free to tweak it or let me know how you’d like it to change and I can adjust the PR.
FYI for anybody else that lands here, the bug has been fixed in Chrome Canary: https://www.google.com/intl/en/chrome/browser/canary.html
@cyrus-and perhaps we should comment about this in the readme where appropriate? If you agree I’ll open a PR.