Index: test/wrappers/pages.js |
=================================================================== |
--- a/test/wrappers/pages.js |
+++ b/test/wrappers/pages.js |
@@ -58,31 +58,27 @@ |
return element.takeScreenshot().then( |
imageFromBase64, |
// Chrome doesn't support taking screenshots of individual elements. So as |
// a workaround, we scroll to the position of the element, take a screenshot |
// 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.getRect().then(rect => |
element.getDriver().executeScript(` |
- window.scrollTo(${loc.x}, ${loc.y}); |
+ window.scrollTo(${rect.x}, ${rect.y}); |
return [window.scrollX, window.scrollY]; |
`).then(result => |
{ |
- let x = loc.x - result[0]; |
- let y = loc.y - result[1]; |
+ let x = rect.x - result[0]; |
+ let y = rect.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, rect.width, rect.height)); |
}) |
) |
).then(img => img.bitmap); |
} |
function getSections(driver) |
{ |
return driver.findElements(By.css("section")).then(elements => |