selenium webdriver chrome headless

Developer from somewhere

Problem: wanted to use chrome headless in selenium tests.

Solution: found here. Since I’m using chrome 61, I don’t need to set the binary to chrome.

    const options = new chromeDriver.Options()
    options.addArguments(
        'headless',
        // Use --disable-gpu to avoid an error from a missing Mesa library, as per
        // https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
        'disable-gpu',
    )
    const browser = new webdriver.Builder()
        .forBrowser(targetBrowser)
        .setChromeOptions(options)
        .build();
    // ... do your thing here