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

Screenshots are blank after resizing browser on 1.2.0 #63

Closed neilsarkar closed 6 years ago

neilsarkar commented 6 years ago

Hi there, and thanks for this amazing library!

I'm trying to resize the browser window in order to capture automated full page screenshots for various screen sizes, but I'm seeing an issue where screenshots are always blank after resizing the browser window.

I'm using navalia 1.2.0 on mac os 10.12.06 with chrome 61.0.3163.100

I've created a minimal reproduction case here:

const { Chrome } = require('navalia')
const chrome = new Chrome()
const fs = require('fs')

chrome
  .goto('https://google.com')
  .then(() => chrome.screenshot('body'))
  .then((img) => fs.writeFileSync('yep.png', img))
  .then(() => chrome.size(640,640))
  .then(() => chrome.screenshot('body'))
  .then((img) => fs.writeFileSync('nope.png', img))
  .then(() => chrome.done())

And here is yep.png:

yep

and nope.png:

nope

I'd be happy to submit a PR to fix this, but am at a bit of a loss as to how to debug since I'm not sure how to get some visibility into the execution of the chromedriver process. Any tips there would be much appreciated!

neilsarkar commented 6 years ago

Heh, ok, so I set the browser size to be larger, for e.g. 320x1200 and it took a valid screenshot. It appears that it was just capturing a square of whitespace on the google home page. Closing this :)