Skip to content

Commit

Permalink
fix(assertView): do not fall when trying to take screenshot of the vi…
Browse files Browse the repository at this point in the history
…ewport
  • Loading branch information
sipayRT committed Sep 6, 2024
1 parent 20318df commit 8fa3599
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/browser/client-scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,13 @@ function prepareScreenshotUnsafe(areas, opts) {
} else if (allowViewportOverflow && viewPort.rectIntersects(rect)) {
rect.overflowsTopBound(viewPort) && rect.recalculateHeight(viewPort);
rect.overflowsLeftBound(viewPort) && rect.recalculateWidth(viewPort);
} else if (!captureElementFromTop && !viewPort.rectIntersects(rect)) {
} else if (!captureElementFromTop && !allowViewportOverflow && !viewPort.rectIntersects(rect)) {
return {
error: "OUTSIDE_OF_VIEWPORT",
message:
"Can not capture element, because it is outside of viewport. " +
'Try to set "captureElementFromTop=true" to scroll to it before capture.'
'Try to set "captureElementFromTop=true" to scroll to it before capture' +
' or to set "allowViewportOverflow=true" to ignore viewport overflow error.'
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/browser/commands/assert-view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ module.exports.default = browser => {
};

const assertViewByViewport = async (state, opts) => {
opts = _.defaults(opts, {
opts = Object.assign(opts, {
allowViewportOverflow: true,
compositeImage: false,
captureElementFromTop: false,
Expand Down

0 comments on commit 8fa3599

Please sign in to comment.