Skip to content

Commit

Permalink
Fix elements hiding behavior for full screen shot (#66)
Browse files Browse the repository at this point in the history
* Fix elements hiding behavior for full screen shot

* Set composer version to 1.0.0 in CI

According to dev requirements of hirak/prestissimo package

* Change test screenshot files

TimeComparisonCest.dontSeeVisualChanges.block2.png
TimeComparisonCest.dontSeeVisualChangesAndHideElement.hideTheBlock.png
  • Loading branch information
mgerasimchuk authored Jan 11, 2021
1 parent d688df7 commit 5ff7ad8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docker/php.docker
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN docker-php-ext-configure zip --with-libzip=/usr/include \
&& docker-php-ext-install zip

# composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
&& /usr/local/bin/composer global require hirak/prestissimo \
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --version=1.0.0 --filename=composer \
&& /usr/local/bin/composer global require hirak/prestissimo "0.3.10" \
&& rm -rf /root/.composer/cache/*

6 changes: 4 additions & 2 deletions module/VisualCeption.php
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ private function createScreenshot($identifier, array $coords, array $excludeElem
$elementPath = $this->getScreenshotPath($identifier);
$screenShotImage = new \Imagick();

$this->hideElementsForScreenshot($excludeElements);

if ($this->config["fullScreenShot"] == true) {
$height = $this->webDriver->executeScript("var ele=document.querySelector('html'); return ele.scrollHeight;");
list($viewportHeight, $devicePixelRatio) = $this->webDriver->executeScript("return [window.innerHeight, window.devicePixelRatio]");
Expand All @@ -408,15 +410,15 @@ private function createScreenshot($identifier, array $coords, array $excludeElem
$fullShot->writeImage($elementPath);

} else {
$this->hideElementsForScreenshot($excludeElements);
$screenshotBinary = $this->webDriver->takeScreenshot();
$this->resetHideElementsForScreenshot($excludeElements);

$screenShotImage->readimageblob($screenshotBinary);
$screenShotImage->cropImage($coords['width'], $coords['height'], $coords['offset_x'], $coords['offset_y']);
$screenShotImage->writeImage($elementPath);
}

$this->resetHideElementsForScreenshot($excludeElements);

return $elementPath;
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5ff7ad8

Please sign in to comment.