Update locators for Paypal flow

This commit is contained in:
JennyNou 2026-03-02 14:35:53 -05:00
parent 75e84452a8
commit 5908b7b807
2 changed files with 29 additions and 22 deletions

View file

@ -235,6 +235,7 @@ const defaultAfterpayDetails: IPaymentDetails = {
const defaultPaypalDetails: IPaymentDetails = {
paymentType: PaymentType.Paypal,
username:'Itqatest@safelite.com',
password: 'Safelite1'
}

View file

@ -1,27 +1,33 @@
import { expect, type Locator, type Page } from '@playwright/test';
import { BasePage } from './BasePage';
import { IPaymentDetails } from '@business-logic/types/CustomerDetails';
import { expect, type Locator, type Page } from "@playwright/test";
import { BasePage } from "./BasePage";
import { IPaymentDetails } from "@business-logic/types/CustomerDetails";
export class PaypalPage extends BasePage {
readonly page: Page;
readonly loginWithPasswordButton: Locator;
readonly passwordTextBox: Locator;
readonly paypalLoginButton: Locator;
readonly completePurchaseButton: Locator;
readonly page: Page;
readonly usernameTextBox: Locator;
readonly nextButton: Locator;
readonly passwordTextBox: Locator;
readonly paypalLoginButton: Locator;
readonly payButton: Locator;
constructor(page: Page) {
super(page);
this.page = page;
this.loginWithPasswordButton = page.getByRole('link', { name: 'Log in with a password instead' });
this.passwordTextBox = page.getByPlaceholder('Password');
this.paypalLoginButton = page.getByRole('button', { name: 'Log In', exact: true });
this.completePurchaseButton = page.getByTestId('submit-button-initial');
}
constructor(page: Page) {
super(page);
this.page = page;
this.usernameTextBox = page.locator("#email");
this.nextButton = page.getByRole("button", { name: "Next" });
this.passwordTextBox = page.getByRole("textbox", { name: "Password" });
this.paypalLoginButton = page.getByRole("button", {
name: "Log In",
exact: true,
});
this.payButton = page.getByRole("button", { name: "Pay $" });
}
async completePaypalPurchase(paymentDetails: IPaymentDetails){
await this.loginWithPasswordButton.click();
await this.passwordTextBox.fill(paymentDetails.password!);
await this.paypalLoginButton.click();
await this.completePurchaseButton.click();
}
async completePaypalPurchase(paymentDetails: IPaymentDetails) {
await this.usernameTextBox.fill(paymentDetails.username!);
await this.nextButton.click();
await this.passwordTextBox.fill(paymentDetails.password!);
await this.paypalLoginButton.click();
await this.payButton.click();
}
}