public function _failed(TestCase $test, $fail) { if (!$this->client || !$this->client->getInternalResponse()) { return; } $this->_savePageSource(codecept_output_dir() . str_replace(['::', '\\', '/'], ['.', '.', '.'], TestCase::getTestSignature($test)) . '.fail.html'); }
public function _failed(TestCase $test, $fail) { if (!$this->client || !$this->client->getInternalResponse()) { return; } $filename = str_replace(['::', '\\', '/'], ['.', '', ''], TestCase::getTestSignature($test)) . '.fail.html'; file_put_contents(codecept_output_dir($filename), $this->client->getInternalResponse()->getContent()); }
public function _failed(TestInterface $test, $fail) { if (!$this->client || !$this->client->getInternalResponse()) { return; } $filename = preg_replace('~\\W~', '.', Descriptor::getTestSignature($test)); $filename = mb_strcut($filename, 0, 244, 'utf-8') . '.fail.html'; $this->_savePageSource(codecept_output_dir() . $filename); }
/** * {@inheritDoc} * * Starts the connection */ public function _reconfigure($config = array()) { parent::_reconfigure($config); if (!isset($this->config['username'])) { throw new \Exception("Sauce Connect Extension requires a username."); } if (!isset($this->config['accesskey'])) { throw new \Exception("Sauce Connect Extension requires a accesskey."); } $connect = __DIR__ . '/../../../bin/sauce_connect'; if (!file_exists($connect)) { $connect = __DIR__ . '/../../../../bin/sauce_connect'; } if (!file_exists($connect)) { throw new \Exception("Couldnt find the bin directory... Make sure its in ./bin or ./vendor/bin/"); } $processBuilder = new ProcessBuilder([$connect]); $processBuilder->addEnvironmentVariables(['SAUCE_USERNAME' => $this->config['username'], 'SAUCE_ACCESS_KEY' => $this->config['accesskey']]); $timeout = isset($this->config['timeout']) ? $this->config['timeout'] : 60; $this->process = $processBuilder->getProcess(); $this->process->setTimeout(0); $this->process->start(function ($type, $buffer) { $buffer = explode("\n", $buffer); foreach ($buffer as $line) { if (strpos($line, 'Press any key to see more output') === false) { file_put_contents(codecept_output_dir() . 'sauce_connect.log', $line . "\n", FILE_APPEND); } } }); $timer = 0; $connected = false; $this->writeln(["", "----------------------------------------------------------------------------", "Attempting to connect to SauceLabs. Waiting {$timeout} seconds."]); while ($this->process->isRunning() && $timer < $timeout) { $output = $this->process->getOutput(); if (strpos($output, 'Connected! You may start your tests.') !== false) { $connected = true; break; } sleep(1); $timer++; if ($timer % 5 === 0) { $this->write('.'); } } if (false === $connected) { $this->process->stop(); throw new \Exception(sprintf("Could not start tunnel. Check %ssauce_connect.log for more information.", codecept_output_dir())); } $this->writeln(["", "Connected to SauceLabs", "----------------------------------------------------------------------------", ""]); }
protected function failureDescription($other) { $page = substr($other, 0, 300); $message = new Message($page); $message->style('info'); $message->prepend("\n--> "); $message->prepend($this->uriMessage()); if (strlen($other) > 300) { $debugMessage = new Message("[Content too long to display. See complete response in '" . codecept_output_dir() . "' directory]"); $debugMessage->style('debug')->prepend("\n"); $message->append($debugMessage); } $message->append("\n--> "); return $message->getMessage() . $this->toString(); }
/** * Run visual inspection on browser. */ public function eyeball($name) { $filebase = codecept_output_dir() . $name; $dirname = dirname($filebase); if (!file_exists($dirname)) { mkdir($dirname, 0777, true); } $oldFile = $filebase . self::SUFFIX; $newFile = $filebase . self::NEWSUFFIX; $diffFile = $filebase . self::DIFFSUFFIX; $this->getModule('WebDriver')->_saveScreenshot($newFile); if (file_exists($oldFile)) { if ($this->comparer->difference($oldFile, $newFile, $diffFile) > 0) { $this->changes[] = $filebase; } else { // Remove the new and diff when no changes detected. unlink($newFile); unlink($diffFile); } } else { // New file, add it to the list. $this->changes[] = $filebase; } }
private function absolutePath($path) { if (strpos($path, '/') === 0 or strpos($path, ':') === 1) { // absolute path return $path; } return codecept_output_dir() . $path; }
public function _failed(TestInterface $test, $fail) { $this->debugWebDriverLogs(); $filename = str_replace([':', '\\', '/'], ['.', '', ''], Descriptor::getTestSignature($test)) . '.fail'; $this->_saveScreenshot(codecept_output_dir() . $filename . '.png'); $this->_savePageSource(codecept_output_dir() . $filename . '.html'); $this->debug("Screenshot and page source were saved into '_output' dir"); }
public function _failed(\Codeception\TestCase $test, $fail) { $filename = str_replace(['::', '\\', '/'], ['.', '', ''], \Codeception\TestCase::getTestSignature($test)) . '.fail.png'; $this->_saveScreenshot(codecept_output_dir($filename)); $this->debug("Screenshot was saved into '_output' dir"); }
public function persist(TestEvent $e) { if (!$this->webDriverModule or !$this->dir) { return; } $indicatorHtml = ''; $slideHtml = ''; foreach ($this->slides as $i => $step) { $indicatorHtml .= (new Template($this->indicatorTemplate))->place('step', (int) $i)->place('isActive', (int) $i ? '' : 'class="active"')->produce(); $slideHtml .= (new Template($this->slidesTemplate))->place('image', $i)->place('caption', $step->getHumanizedArguments())->place('isActive', (int) $i ? '' : 'active')->place('isError', $step->hasFailed() ? 'error' : '')->produce(); } $html = (new Template($this->template))->place('indicators', $indicatorHtml)->place('slides', $slideHtml)->place('feature', ucfirst($e->getTest()->getFeature()))->place('test', TestCase::getTestSignature($e->getTest()))->produce(); $indexFile = $this->dir . DIRECTORY_SEPARATOR . 'index.html'; file_put_contents($indexFile, $html); $testName = TestCase::getTestSignature($e->getTest()) . ' - ' . ucfirst($e->getTest()->getFeature()); $this->recordedTests[$testName] = substr($indexFile, strlen(codecept_output_dir())); }
public function afterResult() { if ($this->options['html']) { $path = codecept_output_dir() . $this->options['html']; $this->output->writeln("- <bold>HTML</bold> report generated in <comment>file://{$path}</comment>"); } if ($this->options['xml']) { $path = codecept_output_dir() . $this->options['xml']; $this->output->writeln("- <bold>XML</bold> report generated in <comment>{$path}</comment>"); } if ($this->options['tap']) { $path = codecept_output_dir() . $this->options['tap']; $this->output->writeln("- <bold>TAP</bold> report generated in <comment>{$path}</comment>"); } if ($this->options['json']) { $path = codecept_output_dir() . $this->options['json']; $this->output->writeln("- <bold>JSON</bold> report generated in <comment>{$path}</comment>"); } }
public function before(TestEvent $e) { $this->dir = null; $this->stepNum = 0; $this->slides = []; $testName = str_replace(['::', '\\', '/'], ['.', '', ''], TestCase::getTestSignature($e->getTest())); $this->dir = codecept_output_dir() . "record_{$this->seed}_{$testName}"; mkdir($this->dir); }
public function _failed(\Codeception\TestCase $test, $fail) { $filename = str_replace(['::', '\\', '/'], ['.', '', ''], \Codeception\TestCase::getTestSignature($test)) . '.fail'; $this->_saveScreenshot(codecept_output_dir() . $filename . '.png'); file_put_contents(codecept_output_dir() . $filename . '.html', $this->webDriver->getPageSource()); $this->debug("Screenshot and HTML snapshot were saved into '_output' dir"); }
public function _failed(\Codeception\TestCase $test, $fail) { $filename = str_replace(['::', '\\', '/'], ['.', '', ''], \Codeception\TestCase::getTestSignature($test)) . '.fail'; $this->_saveScreenshot(codecept_output_dir() . $filename . '.png'); $this->_savePageSource(codecept_output_dir() . $filename . '.html'); $this->debug("Screenshot and page source were saved into '_output' dir"); }
public function _failed(TestInterface $test, $fail) { $this->debugWebDriverLogs(); $filename = preg_replace('~\\W~', '.', Descriptor::getTestSignature($test)); $outputDir = codecept_output_dir(); $this->_saveScreenshot($outputDir . mb_strcut($filename, 0, 245, 'utf-8') . '.fail.png'); $this->_savePageSource($outputDir . mb_strcut($filename, 0, 244, 'utf-8') . '.fail.html'); $this->debug("Screenshot and page source were saved into '{$outputDir}' dir"); }