Load full-window page before adjusting browser window size

Experimenting with selenium-webdriver@3.0.1 and Firefox 50.1.0 I observed
screenshots having a height of merely 8 pixels.  Presumably the margin or
padding of an otherwise empty document.  So in order to get the actual size
of the document area, the screenshotter now loads a document which fills the
entire viewport.
This commit is contained in:
Martin von Gagern
2017-01-03 15:43:35 +01:00
parent 7c83021009
commit ca1a511cc4

View File

@@ -239,6 +239,13 @@ function buildDriver() {
}
driver = builder.build();
driver.manage().timeouts().setScriptTimeout(3000).then(function() {
var html = '<!DOCTYPE html>' +
'<html><head><style type="text/css">html,body{' +
'width:100%;height:100%;margin:0;padding:0;overflow:hidden;' +
'}</style></head><body><p>Test</p></body></html>';
html = "data:text/html," + encodeURIComponent(html);
return driver.get(html);
}).then(function() {
setSize(targetW, targetH);
});
}