Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Codeception/VisualCeption
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: zzhelqzkov/VisualCeption
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on May 5, 2023

  1. Copy the full SHA
    9cf2aaf View commit details
  2. Copy the full SHA
    a344329 View commit details
Showing with 12 additions and 6 deletions.
  1. +12 −6 src/Codeception/Module/VisualCeption.php
18 changes: 12 additions & 6 deletions src/Codeception/Module/VisualCeption.php
Original file line number Diff line number Diff line change
@@ -476,17 +476,23 @@ private function createScreenshot($identifier, array $coords, array $excludeElem
list($viewportHeight, $devicePixelRatio) = $this->webDriver->executeScript("return [window.innerHeight, window.devicePixelRatio]");

$itr = $height / $viewportHeight;
$isViewPortHeightBiggerThanPageHeight = $height > $viewportHeight;

for ($i = 0; $i < (int)$itr; $i++) {
$screenshotBinary = $this->webDriver->takeScreenshot();
$screenShotImage->readimageblob($screenshotBinary);
$this->webDriver->executeScript("window.scrollBy(0, {$viewportHeight});");
if ($isViewPortHeightBiggerThanPageHeight) {
for ($i = 0; $i < intval($itr); $i++) {
$screenshotBinary = $this->webDriver->takeScreenshot();
$screenShotImage->readimageblob($screenshotBinary);
$this->webDriver->executeScript("window.scrollBy(0, {$viewportHeight});");
}
}

$screenshotBinary = $this->webDriver->takeScreenshot();
$screenShotImage->readimageblob($screenshotBinary);
$heightOffset = $viewportHeight - ($height - (intval($itr) * $viewportHeight));
$screenShotImage->cropImage(0, 0, 0, $heightOffset * $devicePixelRatio);
// $heightOffset = $viewportHeight - ($height - (intval($itr) * $viewportHeight));
//
// if ($isViewPortHeightBiggerThanPageHeight) {
// $screenShotImage->cropImage(0, 0, 0, $heightOffset * $devicePixelRatio);
// }

$screenShotImage->resetIterator();
$fullShot = $screenShotImage->appendImages(true);