webdrivercss icon indicating copy to clipboard operation
webdrivercss copied to clipboard

saveDocumentScreenshot first screenshot taken too early

Open albertogasparin opened this issue 9 years ago • 1 comments

I'm having an issue with a quite complex (and heavy) page. Apparently the first screenshot of the full document composition is taken before the overflow hidden (and hide/exclude) gets applied.

You can clearly see the cut of the images and the scrollbar "disappearing" homepage-1024

Code used:

client
    .init()
    .windowHandleSize({ width: 1024, height: 768 })
    .url('https://ww2.thomascook.com')
    .pause(5000)
    .webdrivercss( 'home', {
        name: '1024',
        hide: ['.productDealsBox .linkBoxImage .panel-image'],
      }, function(err, res) {
        assert.ifError(err);
        assert.ok(res.isWithinMisMatchTolerance);
      }
    )
    .end();

albertogasparin avatar May 20 '15 14:05 albertogasparin

I can confirm this. I think there's no reliable cross-browser solution to detect when the reflow finishes, so what I do as a workaround is adding a short pause after hiding the scrollbars:

client.addCommand('myWebdrivercss', function (pagename, args, cb) {
  client.execute(function() {
      document.body.style.overflow = 'hidden';
    })
    .pause(500)
    .webdrivercss(pagename, args, cb);
});

so there is 500ms reserved for the reflow.

adrianolek avatar Aug 24 '15 17:08 adrianolek