/** * Compare the reference image with a current screenshot, identified by their indentifier name * and their element ID. * * @param string $identifier identifies your test object * @param string $elementID DOM ID of the element, which should be screenshotted * @throws \Codeception\Module\ImageDeviationException * @throws \RuntimeException */ public function dontSeeVisualChanges($identifier, $elementID = 'body') { $environment = $this->test->getScenario()->current('env'); if ($environment) { $identifier = $identifier . '.' . $environment; } $deviationResult = $this->getScreenshotDeviation($identifier, $elementID); if ($deviationResult['deviationImage'] instanceof Imagick) { // used for assertion counter in codeception / phpunit $this->assertTrue(true); if ($deviationResult['deviation'] > $this->maximumDeviation) { $compareScreenshotPath = $this->getDeviationScreenshotPath($identifier); $deviationResult['deviationImage']->writeImage($compareScreenshotPath); throw new ImageDeviationException('The deviation of the taken screenshot is too high - ' . $deviationResult['deviation'] . '.' . PHP_EOL . 'See ' . $compareScreenshotPath . ' for a deviation screenshot.', $this->getReferenceScreenshotPath($identifier), $this->getScreenshotPath($identifier), $compareScreenshotPath); } } }