Skip to content

Commit bce86c4

Browse files
authored
Merge branch 'develop' into MQE-1729
2 parents d5ff5f5 + 3e0d666 commit bce86c4

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/Magento/FunctionalTestingFramework/Module/MagentoWebDriver.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Magento\FunctionalTestingFramework\Util\Protocol\CurlTransport;
2020
use Magento\FunctionalTestingFramework\Util\Protocol\CurlInterface;
2121
use Magento\FunctionalTestingFramework\Util\ConfigSanitizerUtil;
22+
use Yandex\Allure\Adapter\AllureException;
2223
use Yandex\Allure\Adapter\Support\AttachmentSupport;
2324
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
2425

@@ -196,6 +197,7 @@ public function _getCurrentUri()
196197
*
197198
* @param string $url
198199
* @return void
200+
* @throws AllureException
199201
*/
200202
public function dontSeeCurrentUrlEquals($url)
201203
{
@@ -210,6 +212,7 @@ public function dontSeeCurrentUrlEquals($url)
210212
*
211213
* @param string $regex
212214
* @return void
215+
* @throws AllureException
213216
*/
214217
public function dontSeeCurrentUrlMatches($regex)
215218
{
@@ -224,6 +227,7 @@ public function dontSeeCurrentUrlMatches($regex)
224227
*
225228
* @param string $needle
226229
* @return void
230+
* @throws AllureException
227231
*/
228232
public function dontSeeInCurrentUrl($needle)
229233
{
@@ -261,6 +265,7 @@ public function grabFromCurrentUrl($regex = null)
261265
*
262266
* @param string $url
263267
* @return void
268+
* @throws AllureException
264269
*/
265270
public function seeCurrentUrlEquals($url)
266271
{
@@ -275,6 +280,7 @@ public function seeCurrentUrlEquals($url)
275280
*
276281
* @param string $regex
277282
* @return void
283+
* @throws AllureException
278284
*/
279285
public function seeCurrentUrlMatches($regex)
280286
{
@@ -289,6 +295,7 @@ public function seeCurrentUrlMatches($regex)
289295
*
290296
* @param string $needle
291297
* @return void
298+
* @throws AllureException
292299
*/
293300
public function seeInCurrentUrl($needle)
294301
{
@@ -645,6 +652,7 @@ public function dragAndDrop($source, $target, $xOffset = null, $yOffset = null)
645652
* @param string $field
646653
* @param string $value
647654
* @return void
655+
* @throws TestFrameworkException
648656
*/
649657
public function fillSecretField($field, $value)
650658
{
@@ -791,4 +799,29 @@ public function dontSeeJsError()
791799
{
792800
$this->assertEmpty($this->jsErrors, $this->getJsErrors());
793801
}
802+
803+
/**
804+
* Takes a screenshot of the current window and saves it to `tests/_output/debug`.
805+
*
806+
* This function is copied over from the original Codeception WebDriver so that we still have visibility of
807+
* the screenshot filename to be passed to the AllureHelper.
808+
*
809+
* @param string $name
810+
* @return void
811+
* @throws AllureException
812+
*/
813+
public function makeScreenshot($name = null)
814+
{
815+
if (empty($name)) {
816+
$name = uniqid(date("Y-m-d_H-i-s_"));
817+
}
818+
$debugDir = codecept_log_dir() . 'debug';
819+
if (!is_dir($debugDir)) {
820+
mkdir($debugDir, 0777);
821+
}
822+
$screenName = $debugDir . DIRECTORY_SEPARATOR . $name . '.png';
823+
$this->_saveScreenshot($screenName);
824+
$this->debug("Screenshot saved to $screenName");
825+
AllureHelper::addAttachmentToCurrentStep($screenName, 'Screenshot');
826+
}
794827
}

0 commit comments

Comments
 (0)