From df2644f65ab41425f41c0f3013139d5b3e92ebc8 Mon Sep 17 00:00:00 2001 From: Cenk Kucukiravul Date: Thu, 21 Dec 2023 13:05:49 +0100 Subject: [PATCH] Update v9 Product Detail page objects to have express checkout support --- .../pageObjects/plugin/ProductDetail.page.js | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/projects/magento/pageObjects/plugin/ProductDetail.page.js b/projects/magento/pageObjects/plugin/ProductDetail.page.js index 91edce15..486090a2 100644 --- a/projects/magento/pageObjects/plugin/ProductDetail.page.js +++ b/projects/magento/pageObjects/plugin/ProductDetail.page.js @@ -5,21 +5,36 @@ export class ProductDetailsPage extends BasePage { constructor(page) { super(page); this.page = page; + this.firstColorOption = page .locator("//*[contains(@class,'swatch-option color')]") .first(); this.quantityField = page.locator("input[name='qty']"); this.addToCartButton = page.locator("#product-addtocart-button"); + + this.productDetailActionsWrapper = page.locator(".box-tocart"); + this.buyWithGoogleViaProductPageButton = this.productDetailActionsWrapper + .locator(".adyen-checkout__paywithgoogle"); + this.buyWithGoogleViaProductPageButtonAnimation = this.productDetailActionsWrapper + .locator(".gpay-card-info-animated-progress-bar"); } - async addItemToCart(itemURL) { + async navigateToItemPage(itemURL){ await this.page.goto(`/${itemURL}`); + } + + async addToCart(){ await this.addToCartButton.click(); await new AnimationHelper(this.page).waitForAnimation(); } + async addItemToCart(itemURL) { + await this.navigateToItemPage(itemURL); + await this.addToCart(); + } + async addItemWithOptionsToCart(itemURL, itemSize = "S", howMany = 1) { - await this.page.goto(`/${itemURL}`); + await this.navigateToItemPage(itemURL); await this.page.locator(`[aria-label='${itemSize.toUpperCase()}']`).click(); await this.firstColorOption.click(); await this.quantityField.fill(howMany.toString()); @@ -30,4 +45,11 @@ export class ProductDetailsPage extends BasePage { the animation and the item number update */ await new Promise(resolve => setTimeout(resolve, 100)); } + + async clickBuyWithGPay(){ + await (this.buyWithGoogleViaProductPageButtonAnimation).waitFor({state: "visible"}); + await (this.buyWithGoogleViaProductPageButton).waitFor({state: "visible"}); + await this.page.waitForLoadState("networkidle", { timeout: 10000 }); + await this.buyWithGoogleViaProductPageButton.click(); + } }