webdrivercss
webdrivercss copied to clipboard
saveDocumentScreenshot first screenshot taken too early
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"
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();
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.