@@ -272,12 +272,18 @@ function bankRedirectRedirection(
272
272
}
273
273
274
274
cy . then ( ( ) => {
275
- verifyReturnUrl ( redirection_url , expected_url , verifyUrl ) ;
275
+ try {
276
+ verifyReturnUrl ( redirection_url , expected_url , verifyUrl ) ;
277
+ } catch ( error ) {
278
+ cy . log ( "Error during return URL verification:" , error ) ;
279
+ throw error ;
280
+ }
276
281
} ) ;
277
282
}
278
283
279
284
function threeDsRedirection ( redirection_url , expected_url , connectorId ) {
280
285
cy . visit ( redirection_url . href ) ;
286
+
281
287
if ( connectorId === "adyen" ) {
282
288
cy . get ( "iframe" )
283
289
. its ( "0.contentDocument.body" )
@@ -286,17 +292,32 @@ function threeDsRedirection(redirection_url, expected_url, connectorId) {
286
292
cy . get ( 'input[type="password"]' ) . type ( "password" ) ;
287
293
cy . get ( "#buttonSubmit" ) . click ( ) ;
288
294
} ) ;
289
- } else if (
290
- connectorId === "bankofamerica" ||
291
- connectorId === "cybersource" ||
292
- connectorId === "wellsfargo"
293
- ) {
295
+ } else if ( connectorId === "bankofamerica" || connectorId === "wellsfargo" ) {
296
+ // Wait for iframe to be present and visible
294
297
cy . get ( "iframe" , { timeout : TIMEOUT } )
298
+ . should ( "be.visible" )
295
299
. its ( "0.contentDocument.body" )
300
+ . should ( "not.be.empty" ) // Ensure body has content
296
301
. within ( ( ) => {
297
- cy . get ( 'input[type="text"]' ) . click ( ) . type ( "1234" ) ;
298
- cy . get ( 'input[value="SUBMIT"]' ) . click ( ) ;
302
+ // Add retry ability and multiple selector attempts
303
+ cy . get (
304
+ 'input[type="text"], input[type="password"], input[name="challengeDataEntry"]' ,
305
+ { timeout : TIMEOUT }
306
+ )
307
+ . should ( "be.visible" )
308
+ . should ( "be.enabled" )
309
+ . click ( )
310
+ . type ( "1234" ) ;
311
+
312
+ cy . get ( 'input[value="SUBMIT"], button[type="submit"]' , {
313
+ timeout : TIMEOUT ,
314
+ } )
315
+ . should ( "be.visible" )
316
+ . click ( ) ;
299
317
} ) ;
318
+ } else if ( connectorId === "cybersource" ) {
319
+ cy . url ( { timeout : TIMEOUT } ) . should ( "include" , expected_url . origin ) ;
320
+ return ; // this is mandatory, else refunds section will fail with unhandled promise rejections even though it is handled
300
321
} else if ( connectorId === "checkout" ) {
301
322
cy . get ( "iframe" , { timeout : TIMEOUT } )
302
323
. its ( "0.contentDocument.body" )
@@ -381,7 +402,12 @@ function threeDsRedirection(redirection_url, expected_url, connectorId) {
381
402
}
382
403
383
404
cy . then ( ( ) => {
384
- verifyReturnUrl ( redirection_url , expected_url , true ) ;
405
+ try {
406
+ verifyReturnUrl ( redirection_url , expected_url , true ) ;
407
+ } catch ( error ) {
408
+ cy . log ( "Error during return URL verification:" , error ) ;
409
+ throw error ;
410
+ }
385
411
} ) ;
386
412
}
387
413
@@ -422,7 +448,12 @@ function upiRedirection(
422
448
}
423
449
424
450
cy . then ( ( ) => {
425
- verifyReturnUrl ( redirection_url , expected_url , verifyUrl ) ;
451
+ try {
452
+ verifyReturnUrl ( redirection_url , expected_url , verifyUrl ) ;
453
+ } catch ( error ) {
454
+ cy . log ( "Error during return URL verification:" , error ) ;
455
+ throw error ;
456
+ }
426
457
} ) ;
427
458
}
428
459
0 commit comments