title: How to take screenshot in headless mode in test framework with protractor/cucumber/typescript
body: <p>I want to execute my test cases on headless mode and capture screenshots on failure.</p>
  <p>I have included the below lines of code to run in the headless mode.</p>
  <pre><code>chromeOptions: {args: [ 'no-sandbox',&quot;--headless&quot;, &quot;--disable-gpu&quot;,  &quot;--window-size=800,600&quot; ]},
  </code></pre>
  <p>This executes the test cases in the headless mode without issues. But on failure, it attaches white blank screenshot with the below code.</p>
  <pre><code>const screenshot = await browser.takeScreenshot();
  scenario.attach(new Buffer(screenshot, 'base64'), &quot;image/png&quot;);  
  </code></pre>