From d8a8afedee26a163f69d21f6ab9572d5212bfc3a Mon Sep 17 00:00:00 2001 From: Tom Reece Date: Wed, 4 Sep 2019 11:28:07 -0500 Subject: [PATCH 1/2] MQE-1692: Improve makeScreenshot Action to Add Screenshot to Allure Report - Initial implementation --- .../Module/MagentoWebDriver.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index 731643eaf..5ab5cc1ca 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -19,6 +19,7 @@ use Magento\FunctionalTestingFramework\Util\Protocol\CurlTransport; use Magento\FunctionalTestingFramework\Util\Protocol\CurlInterface; use Magento\FunctionalTestingFramework\Util\ConfigSanitizerUtil; +use Yandex\Allure\Adapter\AllureException; use Yandex\Allure\Adapter\Support\AttachmentSupport; use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException; @@ -196,6 +197,7 @@ public function _getCurrentUri() * * @param string $url * @return void + * @throws AllureException */ public function dontSeeCurrentUrlEquals($url) { @@ -210,6 +212,7 @@ public function dontSeeCurrentUrlEquals($url) * * @param string $regex * @return void + * @throws AllureException */ public function dontSeeCurrentUrlMatches($regex) { @@ -224,6 +227,7 @@ public function dontSeeCurrentUrlMatches($regex) * * @param string $needle * @return void + * @throws AllureException */ public function dontSeeInCurrentUrl($needle) { @@ -261,6 +265,7 @@ public function grabFromCurrentUrl($regex = null) * * @param string $url * @return void + * @throws AllureException */ public function seeCurrentUrlEquals($url) { @@ -275,6 +280,7 @@ public function seeCurrentUrlEquals($url) * * @param string $regex * @return void + * @throws AllureException */ public function seeCurrentUrlMatches($regex) { @@ -289,6 +295,7 @@ public function seeCurrentUrlMatches($regex) * * @param string $needle * @return void + * @throws AllureException */ public function seeInCurrentUrl($needle) { @@ -645,6 +652,7 @@ public function dragAndDrop($source, $target, $xOffset = null, $yOffset = null) * @param string $field * @param string $value * @return void + * @throws TestFrameworkException */ public function fillSecretField($field, $value) { @@ -791,4 +799,28 @@ public function dontSeeJsError() { $this->assertEmpty($this->jsErrors, $this->getJsErrors()); } + + /** + * Takes a screenshot of the current window and saves it to `tests/_output/debug`. + * + * This function is copied over from the original Codeception WebDriver so that we still have visibility of + * the screenshot filename to be passed to the AllureHelper. + * + * @param string $name + * @throws AllureException + */ + public function makeScreenshot($name = null) + { + if (empty($name)) { + $name = uniqid(date("Y-m-d_H-i-s_")); + } + $debugDir = codecept_log_dir() . 'debug'; + if (!is_dir($debugDir)) { + mkdir($debugDir, 0777); + } + $screenName = $debugDir . DIRECTORY_SEPARATOR . $name . '.png'; + $this->_saveScreenshot($screenName); + $this->debug("Screenshot saved to $screenName"); + AllureHelper::addAttachmentToCurrentStep($screenName, 'Screenshot'); + } } From 7cce52054c07df8aee8cb8969f424811bb7244b1 Mon Sep 17 00:00:00 2001 From: Tom Reece Date: Wed, 4 Sep 2019 12:57:33 -0500 Subject: [PATCH 2/2] MQE-1692: Improve makeScreenshot Action to Add Screenshot to Allure Report - Add missing phpdoc @return --- .../FunctionalTestingFramework/Module/MagentoWebDriver.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php index 5ab5cc1ca..ac6e86c0a 100644 --- a/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php +++ b/src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php @@ -807,6 +807,7 @@ public function dontSeeJsError() * the screenshot filename to be passed to the AllureHelper. * * @param string $name + * @return void * @throws AllureException */ public function makeScreenshot($name = null)