Skip to content

Commit

Permalink
Handle case where viewportHeigh is equal to heighOffset
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhelqzkov committed Sep 20, 2024
1 parent 61b8eee commit 1daed76
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Codeception/Module/VisualCeption.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,12 +521,14 @@ private function createScreenshot($identifier, array $coords, $fullScreenshot, a
}
}

$screenshotBinary = $this->webDriver->takeScreenshot();
$screenShotImage->readimageblob($screenshotBinary);
$heightOffset = $viewportHeight - ($height - (intval($itr) * $viewportHeight));
if (!is_int($itr) || $height <= $viewportHeight) {
$screenshotBinary = $this->webDriver->takeScreenshot();
$screenShotImage->readimageblob($screenshotBinary);
$heightOffset = $viewportHeight - ($height - (intval($itr) * $viewportHeight));

if ($isViewPortHeightBiggerThanPageHeight) {
$screenShotImage->cropImage(0, 0, 0, $heightOffset * $devicePixelRatio);
if ($isViewPortHeightBiggerThanPageHeight) {
$screenShotImage->cropImage(0, 0, 0, $heightOffset * $devicePixelRatio);
}
}

$screenShotImage->resetIterator();
Expand Down

0 comments on commit 1daed76

Please sign in to comment.