Skip to content

Commit

Permalink
Update v9 Product Detail page objects to have express checkout support
Browse files Browse the repository at this point in the history
  • Loading branch information
Cenk Kucukiravul committed Dec 21, 2023
1 parent cfbe046 commit df2644f
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions projects/magento/pageObjects/plugin/ProductDetail.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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();
}
}

0 comments on commit df2644f

Please sign in to comment.