|
2 | 2 | namespace Magento\AcceptanceTestFramework\Module;
|
3 | 3 |
|
4 | 4 | use Codeception\Module\WebDriver;
|
| 5 | +use Codeception\Test\Descriptor; |
| 6 | +use Codeception\TestInterface; |
5 | 7 | use Facebook\WebDriver\WebDriverSelect;
|
6 | 8 | use Facebook\WebDriver\WebDriverBy;
|
7 | 9 | use Facebook\WebDriver\Exception\NoSuchElementException;
|
|
10 | 12 | use Codeception\Exception\ModuleException;
|
11 | 13 | use Codeception\Util\Uri;
|
12 | 14 | use Codeception\Util\ActionSequence;
|
| 15 | +use Yandex\Allure\Adapter\Support\AttachmentSupport; |
13 | 16 |
|
14 | 17 | /**
|
15 | 18 | * MagentoWebDriver module provides common Magento web actions through Selenium WebDriver.
|
|
31 | 34 | */
|
32 | 35 | class MagentoWebDriver extends WebDriver
|
33 | 36 | {
|
| 37 | + use AttachmentSupport; |
34 | 38 | public static $loadingMask = '.loading-mask';
|
35 | 39 |
|
36 | 40 | /**
|
@@ -276,4 +280,23 @@ public function scrollToTopOfPage()
|
276 | 280 | {
|
277 | 281 | $this->executeJS('window.scrollTo(0,0);');
|
278 | 282 | }
|
| 283 | + |
| 284 | + /** |
| 285 | + * Override for _failed method in Codeception method. Adds png and html attachments to allure report |
| 286 | + * following parent execution of test failure processing. |
| 287 | + * @param TestInterface $test |
| 288 | + * @param \Exception $fail |
| 289 | + */ |
| 290 | + public function _failed(TestInterface $test, $fail) |
| 291 | + { |
| 292 | + parent::_failed($test, $fail); |
| 293 | + |
| 294 | + // Reconstruct file naming from codeception method |
| 295 | + $filename = preg_replace('~\W~', '.', Descriptor::getTestSignature($test)); |
| 296 | + $outputDir = codecept_output_dir(); |
| 297 | + $pngReport = $outputDir . mb_strcut($filename, 0, 245, 'utf-8') . '.fail.png'; |
| 298 | + $htmlReport = $outputDir . mb_strcut($filename, 0, 244, 'utf-8') . '.fail.html'; |
| 299 | + $this->addAttachment($pngReport, $test->getMetadata()->getName() . '.png', 'image/png'); |
| 300 | + $this->addAttachment($htmlReport, $test->getMetadata()->getName() . '.html', 'text/html'); |
| 301 | + } |
279 | 302 | }
|
0 commit comments