joelgriffith / navalia

A bullet-proof, fast, and reliable headless browser API
https://joelgriffith.github.io/navalia/
GNU General Public License v3.0
957 stars 33 forks source link

Can't get headless arg to work #46

Open haydenflinner opened 7 years ago

haydenflinner commented 7 years ago

Here's the code I'm trying to run, compiled from two different examples in the docs:

const { Chrome } = require('navalia');
const chrome = new Chrome({chromeOptions: {
    flags: {
      headless: false
    }
  }});
chrome
  .goto('https://amazon.com')
  .type('input', 'Kindle')
  .click('.buy-now')
  .then((responses) => {
    console.log(responses); // ['https://www.amazon.com/', true, true, true]
  });

But when I run it it works as normal, like it did before I added the noheadless arg. Anything obvious I'm doing wrong?

joelgriffith commented 7 years ago

D'oh! I must have it wrong someplace. For the chrome module, you don't need the chromeOptions object. Just pass a simple object with a flags property:

const chrome = new Chrome({ flags: {...} });

Do you recall where you saw this? The Navalia module uses that signature as it's not vendor specific (hence the chromeOptions)

haydenflinner commented 7 years ago

https://joelgriffith.github.io/navalia/navalia/constructor/#chromeoptions