コード例 #1
0
 /**
  * Executes provided step definition.
  *
  * If the result is not a failure then take a screenshot and compare for differences.
  *
  * @param StepNode $step
  * @param DefinitionInterface $definition
  * @throws PerceptualDiffException If there are differences compared to the baseline
  */
 protected function executeStepDefinition(StepNode $step, DefinitionInterface $definition)
 {
     parent::executeStepDefinition($step, $definition);
     $diff = $this->screenshotComparator->takeScreenshot($this->context, $step);
     if ($diff > 0 && $this->failOnDiff) {
         // There were differences between the two screenshots
         throw new PerceptualDiffException(sprintf('There was a perceptual difference of %d', $diff));
     }
 }
コード例 #2
0
 /**
  * Executes provided step definition.
  *
  * If the result is not a failure then take a screenshot and compare for differences.
  *
  * @param StepNode $step
  * @param DefinitionInterface $definition
  * @throws PerceptualDiffException If there are differences compared to the baseline
  */
 protected function executeStepDefinition(StepNode $step, DefinitionInterface $definition)
 {
     parent::executeStepDefinition($step, $definition);
     $session = $this->context->getSession();
     // give JavaScript time to trigger additional ajax requests after onload
     $session->wait(100);
     // Wait for an ajax request to complete, but only for a maximum of X seconds to avoid deadlocks
     $session->wait(5000, "(typeof window.__ajaxStatus !== 'undefined' ? window.__ajaxStatus() : 'no ajax') !== 'waiting'");
     // The 'sleep' config setting will be respected in the comparator logic,
     // and is required to be at least ~200ms to give the browser a chance to finish rendering
     $diff = $this->screenshotComparator->takeScreenshot($this->context, $step);
     if ($diff > 0 && $this->failOnDiff) {
         // There were differences between the two screenshots
         throw new PerceptualDiffException(sprintf('There was a perceptual difference of %d', $diff));
     }
 }