Exemplo n.º 1
0
 /**
  * Logs data in the database and filesystem.
  * A screenshot of the current screen will be created.
  *
  * @param string     $message    Error message.
  * @param string     $txt        Prepared error text.
  * @param string     $screenName Name of screen shot.
  * @param array|null $errorImage (Optional) Existing error image name.
  *
  * @return $this Same instance for chained method calls.
  */
 private function _logData($message, $txt, $screenName, $errorImage = null)
 {
     // scroll to top of the page
     $this->client->scrollTo(0, 0);
     //$this->testSuite->getWebDriver()->executeScript('javascript:window')
     try {
         if ($errorImage) {
             $screenPath = $this->testSuite->getSuiteSettings()->getBranch() . '/' . $this->testSuite->getSuiteSettings()->getSuiteName() . '/' . array_shift($errorImage);
         } else {
             $screenPath = $this->testSuite->getFileLogger()->screenshot($this->testSuite->getWebDriver(), str_replace(' ', '', $screenName));
         }
     } catch (WebDriverCurlException $e) {
         $txt .= 'Failed to take a screen shot, additional error information:' . "\nMessage:\t" . $e->getMessage() . "\nStack Trace:\t" . $e->getTraceAsString() . "\n";
         $screenPath = '';
     }
     $this->testSuite->getFileLogger()->log($txt, 'errors');
     $this->testSuite->getSqlLogger()->caseError($message, $this->testSuite->getWebDriver()->getCurrentURL(), $screenPath);
     $this->addErrorMessages($screenPath, $txt)->failed = true;
     $this->output('TestCaseFailed! ...');
     return $this;
 }