19
19
use Magento \FunctionalTestingFramework \Util \Protocol \CurlTransport ;
20
20
use Magento \FunctionalTestingFramework \Util \Protocol \CurlInterface ;
21
21
use Magento \FunctionalTestingFramework \Util \ConfigSanitizerUtil ;
22
+ use Yandex \Allure \Adapter \AllureException ;
22
23
use Yandex \Allure \Adapter \Support \AttachmentSupport ;
23
24
use Magento \FunctionalTestingFramework \Exceptions \TestFrameworkException ;
24
25
@@ -196,6 +197,7 @@ public function _getCurrentUri()
196
197
*
197
198
* @param string $url
198
199
* @return void
200
+ * @throws AllureException
199
201
*/
200
202
public function dontSeeCurrentUrlEquals ($ url )
201
203
{
@@ -210,6 +212,7 @@ public function dontSeeCurrentUrlEquals($url)
210
212
*
211
213
* @param string $regex
212
214
* @return void
215
+ * @throws AllureException
213
216
*/
214
217
public function dontSeeCurrentUrlMatches ($ regex )
215
218
{
@@ -224,6 +227,7 @@ public function dontSeeCurrentUrlMatches($regex)
224
227
*
225
228
* @param string $needle
226
229
* @return void
230
+ * @throws AllureException
227
231
*/
228
232
public function dontSeeInCurrentUrl ($ needle )
229
233
{
@@ -261,6 +265,7 @@ public function grabFromCurrentUrl($regex = null)
261
265
*
262
266
* @param string $url
263
267
* @return void
268
+ * @throws AllureException
264
269
*/
265
270
public function seeCurrentUrlEquals ($ url )
266
271
{
@@ -275,6 +280,7 @@ public function seeCurrentUrlEquals($url)
275
280
*
276
281
* @param string $regex
277
282
* @return void
283
+ * @throws AllureException
278
284
*/
279
285
public function seeCurrentUrlMatches ($ regex )
280
286
{
@@ -289,6 +295,7 @@ public function seeCurrentUrlMatches($regex)
289
295
*
290
296
* @param string $needle
291
297
* @return void
298
+ * @throws AllureException
292
299
*/
293
300
public function seeInCurrentUrl ($ needle )
294
301
{
@@ -645,6 +652,7 @@ public function dragAndDrop($source, $target, $xOffset = null, $yOffset = null)
645
652
* @param string $field
646
653
* @param string $value
647
654
* @return void
655
+ * @throws TestFrameworkException
648
656
*/
649
657
public function fillSecretField ($ field , $ value )
650
658
{
@@ -791,4 +799,29 @@ public function dontSeeJsError()
791
799
{
792
800
$ this ->assertEmpty ($ this ->jsErrors , $ this ->getJsErrors ());
793
801
}
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
+ }
794
827
}
0 commit comments