| Index: test/wrappers/pages.js | 
| =================================================================== | 
| --- a/test/wrappers/pages.js | 
| +++ b/test/wrappers/pages.js | 
| @@ -23,6 +23,8 @@ | 
| const Jimp = require("jimp"); | 
| const {By, until} = require("selenium-webdriver"); | 
| +let lastScreenshot = Promise.resolve(); | 
| + | 
| // Once we require Node.js >= 10 this should be replaced with | 
| // the built-in finally() method of the Promise object. | 
| function promiseFinally(p, callback) | 
| @@ -63,23 +65,22 @@ | 
| // of the viewport and crop it to the size and position of our element. | 
| // This is not guaranteed to work on other browsers (mostly because | 
| // the behavior of Driver.takeScreenshot() may vary across browsers). | 
| - () => element.getLocation().then(loc => | 
| - element.getDriver().executeScript(` | 
| - window.scrollTo(${loc.x}, ${loc.y}); | 
| - return [window.scrollX, window.scrollY]; | 
| - `).then(result => | 
| - { | 
| - let x = loc.x - result[0]; | 
| - let y = loc.y - result[1]; | 
| + () => | 
| + lastScreenshot = Promise.all([element.getRect(), | 
| + lastScreenshot]).then(([loc]) => | 
| 
 
hub
2018/11/09 22:23:31
you might have taken the wrong version of the patc
 
Sebastian Noack
2018/11/09 22:26:53
Oops, I indeed missed your last patch set. Fixed.
 
 | 
| + element.getDriver().executeScript(` | 
| + window.scrollTo(${loc.x}, ${loc.y}); | 
| + return [window.scrollX, window.scrollY]; | 
| + `).then(result => | 
| + { | 
| + let x = loc.x - result[0]; | 
| + let y = loc.y - result[1]; | 
| - return Promise.all([ | 
| - element.getDriver().takeScreenshot().then(imageFromBase64), | 
| - element.getSize() | 
| - ]).then(([img, size]) => | 
| - img.crop(x, y, size.width, size.height) | 
| - ); | 
| - }) | 
| - ) | 
| + return element.getDriver().takeScreenshot() | 
| + .then(imageFromBase64) | 
| + .then(img => img.crop(x, y, loc.width, loc.height)); | 
| + }) | 
| + ) | 
| ).then(img => img.bitmap); | 
| } |