question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New tab official example not working for headless mode

See original GitHub issue

I must have missed something but executing the official example for creating a new tab in headless mode doesn’t work for me:

const CDP = require('chrome-remote-interface');

CDP.New().then((tab) => {
    return CDP({tab: tab});
}).then((client) => {
    return client.Runtime.evaluate({
        expression: 'alert("Closing this tab...")'
    }).then(() => {
        const tab = client.chooseTab;
        return CDP.Close({id: tab.id});
    });
}).catch((err) => {
    console.error(err);
});

I get: Error: Could not create new page

I tried with the command line: chrome-remote-interface new http://www.ingdirect.fr. Same error.

I’m executing Chrome on Ubuntu. I customized the IP on which chrome listen but I tried with the default (localhost) and I observed same results.

Regarding the command line, inspect and list works. But not new nor close.

[ { description: '',
    devtoolsFrontendUrl: '/devtools/inspector.html?ws=192.168.1.44:9222/devtools/page/49db60ac-cc96-4e0f-bba2-7403f40a82bf',
    id: '49db60ac-cc96-4e0f-bba2-7403f40a82bf',
    title: 'about:blank',
    type: 'page',
    url: 'about:blank',
    webSocketDebuggerUrl: 'ws://192.168.1.44:9222/devtools/page/49db60ac-cc96-4e0f-bba2-7403f40a82bf' } ]

I’m using the latest version of node and CRI:

 npm ls -g --depth=0
/home/jon/.nvm/versions/node/v7.9.0/lib
├── chrome-remote-interface@0.18.0
└── npm@4.2.0

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jeandatcommented, Apr 13, 2017

OK good to know. Saw that but thought DevTools was a domain. Thanks.

1reaction
cyrus-andcommented, Apr 13, 2017

There’s a note about the headless version:

Please note that currently the DevTools methods are not properly supported in headless mode; use the Target domain instead. See #83 and #84 for more information.

It will be fixed in Chrome 59, you can use the google-chrome-unstable Ubuntu package.

Read more comments on GitHub >

github_iconTop Results From Across the Web

3120 - Headless mode download from new tab - chromedriver
Issue 3120: Headless mode download from new tab ... We have the same problem with Chrome 77.0.3865.90. Is there any workaround ?
Read more >
How to download files headless in Selenium (Java) when ...
(But working in non-headless mode). And I found the solution (example in Python):. First step - click Download button and switch to new...
Read more >
Getting Started with Headless Chrome - Chrome Developers
The easiest way to get started with headless mode is to open the Chrome binary from the command line. If you've got Chrome...
Read more >
Working with windows and tabs - Selenium
Clicking a link which opens in a new window will focus the new window or tab on screen, but WebDriver will not know...
Read more >
Multi-tab flows | Checkly
Both Puppeteer and Playwright enable us to control multiple browser tabs, ... Opening tabs directly If we are looking to open brand new...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found