Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New tab official example not working for headless mode #96

Closed
jeandat opened this issue Apr 13, 2017 · 7 comments
Closed

New tab official example not working for headless mode #96

jeandat opened this issue Apr 13, 2017 · 7 comments

Comments

@jeandat
Copy link

jeandat commented Apr 13, 2017

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
├── [email protected]
└── [email protected]
@jeandat jeandat changed the title New tab official example not working for me New tab official example not working for headless mode Apr 13, 2017
@cyrus-and
Copy link
Owner

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.

@jeandat
Copy link
Author

jeandat commented Apr 13, 2017

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

@jeandat
Copy link
Author

jeandat commented Apr 14, 2017

Switching to Chrome 59 unstable resolved several issues I had including creating a new tab.

@pthieu
Copy link

pthieu commented Apr 22, 2017

@jdat82 what OS are you on?

@jeandat
Copy link
Author

jeandat commented Apr 22, 2017

The chrome server was on Ubuntu and the client script on a Mac. Can't wait to get rid of Linux for chrome headless.

@skaliber
Copy link

skaliber commented Sep 27, 2017

@cyrus-and I cant get new tab working using headless
I tried debian and ubuntu docker image and mac os
I tried with a selenium click and running java script to perform the click action for the link that is supposed to open a new tab but it doesnt open

Im using chromedriver 2.3 and google chrome stable 61 and google chrome unstable 63 still doesnt work

can you give me any suggestions how can I get it work ?

@cyrus-and
Copy link
Owner

@skaliber if it's ChromeDriver-related then you may want to take a look at #265, otherwise please file a new issue with all the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants