@@ -57,7 +57,7 @@ export default class CheckoutPageSFRA {
5757
5858 this . shippingSubmit = page . locator ( "button[value='submit-shipping']" ) ;
5959
60- this . submitPaymentButton = page . locator ( "button[value=' submit-payment']" ) ;
60+ this . submitPaymentButton = page . locator ( '. submit-payment') ;
6161 this . placeOrderButton = page . locator ( "button[value='place-order']" ) ;
6262
6363 this . errorMessage = page . locator ( '.error-message-text' ) ;
@@ -89,7 +89,7 @@ export default class CheckoutPageSFRA {
8989
9090 isPaymentModalShown = async ( imgAltValue ) => {
9191 await expect ( this . paymentModal . locator ( `img[alt='${ imgAltValue } ']` ) )
92- . toBeVisible ( { timeout : 20000 } ) ;
92+ . toBeVisible ( ) ;
9393 }
9494
9595 navigateToCheckout = async ( locale ) => {
@@ -102,7 +102,7 @@ export default class CheckoutPageSFRA {
102102
103103 goToCheckoutPageWithFullCart = async ( locale , itemCount = 1 , email ) => {
104104 await this . addProductToCart ( locale , itemCount ) ;
105- await this . successMessage . waitFor ( { visible : true , timeout : 20000 } ) ;
105+ await this . successMessage . waitFor ( { visible : true } ) ;
106106
107107 await this . navigateToCheckout ( locale ) ;
108108 await this . setEmail ( email ) ;
@@ -127,7 +127,7 @@ export default class CheckoutPageSFRA {
127127 } ;
128128
129129 setShopperDetails = async ( shopperDetails ) => {
130- await this . customerInfoSection . waitFor ( { visible : true , timeout : 20000 } ) ;
130+ await this . customerInfoSection . waitFor ( { visible : true } ) ;
131131
132132
133133 await this . checkoutPageUserFirstNameInput . type (
@@ -175,31 +175,26 @@ export default class CheckoutPageSFRA {
175175 } ;
176176
177177 submitShipping = async ( ) => {
178- await this . page . waitForLoadState ( 'networkidle' , { timeout : 20000 } ) ;
178+ await this . page . waitForLoadState ( 'networkidle' ) ;
179179 await this . shippingSubmit . click ( ) ;
180- await this . page . waitForNavigation ( { waitUntil : "networkidle" , timeout : 20000 } ) ;
180+ await this . page . waitForNavigation ( { waitUntil : "networkidle" } ) ;
181181
182182 // Ugly wait since the submit button takes time to mount.
183183 await new Promise ( r => setTimeout ( r , 2000 ) ) ;
184184 } ;
185185
186186 submitPayment = async ( ) => {
187- await this . page . waitForLoadState ( 'load' , { timeout : 30000 } ) ;
188- await this . submitPaymentButton . click ( ) ;
187+ await this . page . waitForFunction ( ( ) => {
188+ const button = document . querySelector ( '.submit-payment' ) ;
189+ return button && ! button . disabled ;
190+ } ) ;
191+
192+ await this . submitPaymentButton . click ( ) ;
189193 } ;
190194
191195 placeOrder = async ( ) => {
192- let retries = 3 ;
193- while ( retries > 0 ) {
194- try {
195- await this . page . waitForLoadState ( 'load' , { timeout : 30000 } ) ;
196- await this . placeOrderButton . click ( ) ;
197- break ; // Break out of the loop if successful
198- } catch ( error ) {
199- retries -- ;
200- await this . page . reload ( ) ;
201- }
202- }
196+ await this . page . waitForLoadState ( 'load' ) ;
197+ await this . placeOrderButton . click ( ) ;
203198 } ;
204199
205200 completeCheckoutLoggedInUser = async ( ) => {
@@ -212,7 +207,7 @@ export default class CheckoutPageSFRA {
212207 } ;
213208
214209 goBackAndSubmitShipping = async ( ) => {
215- await this . page . waitForNavigation ( 'load' , { timeout : 20000 } ) ;
210+ await this . page . waitForNavigation ( 'load' ) ;
216211 await this . navigateBack ( ) ;
217212 await this . submitShipping ( ) ;
218213 } ;
@@ -221,35 +216,34 @@ export default class CheckoutPageSFRA {
221216 expectSuccess = async ( ) => {
222217 await this . page . waitForNavigation ( {
223218 url : / O r d e r - C o n f i r m / ,
224- timeout : 20000 ,
225219 } ) ;
226- await expect ( this . thankYouMessage ) . toBeVisible ( { timeout : 20000 } ) ;
220+ await expect ( this . thankYouMessage ) . toBeVisible ( ) ;
227221 } ;
228222
229223 expectNonRedirectSuccess = async ( ) => {
230- await expect ( this . thankYouMessage ) . toBeVisible ( { timeout : 20000 } ) ;
224+ await expect ( this . thankYouMessage ) . toBeVisible ( ) ;
231225 } ;
232226
233227 expectRefusal = async ( ) => {
234- await expect ( this . errorMessage ) . not . toBeEmpty ( { timeout : 25000 } ) ;
228+ await expect ( this . errorMessage ) . not . toBeEmpty ( ) ;
235229 } ;
236230
237231 expectVoucher = async ( ) => {
238- await expect ( this . voucherCode ) . toBeVisible ( { timeout : 20000 } ) ;
232+ await expect ( this . voucherCode ) . toBeVisible ( ) ;
239233 } ;
240234
241235 expectQRcode = async ( ) => {
242- await this . qrLoader . waitFor ( { state : 'attached' , timeout : 20000 } ) ;
243- await expect ( this . qrLoaderAmount ) . toBeVisible ( { timeout : 20000 } ) ;
244- await expect ( this . qrImg ) . toBeVisible ( { timeout : 20000 } ) ;
236+ await this . qrLoader . waitFor ( { state : 'attached' } ) ;
237+ await expect ( this . qrLoaderAmount ) . toBeVisible ( ) ;
238+ await expect ( this . qrImg ) . toBeVisible ( ) ;
245239 } ;
246240
247241 expectGiftCardWarning = async ( ) => {
248242 await expect ( this . giftCardWarning ) . not . toBeEmpty ( ) ;
249243 } ;
250244
251245 getLocation = async ( ) => {
252- await this . page . waitForLoadState ( 'load' , { timeout : 20000 } ) ;
246+ await this . page . waitForLoadState ( 'load' ) ;
253247 return await this . page . url ( ) ;
254248 } ;
255249
0 commit comments