Merge branch 'CASH-631' into kpatel/Misc_Fix
This commit is contained in:
commit
24615cb76d
1 changed files with 19 additions and 7 deletions
|
|
@ -11,26 +11,38 @@ export class PaypalPage extends BasePage {
|
||||||
readonly passwordTextBox: Locator;
|
readonly passwordTextBox: Locator;
|
||||||
readonly paypalLoginButton: Locator;
|
readonly paypalLoginButton: Locator;
|
||||||
readonly completePurchaseButton: Locator;
|
readonly completePurchaseButton: Locator;
|
||||||
|
readonly payButton: Locator;
|
||||||
|
|
||||||
constructor(page: Page) {
|
constructor(page: Page) {
|
||||||
super(page);
|
super(page);
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.usernameTextBox = page.getByPlaceholder('Email');
|
this.usernameTextBox = page.getByPlaceholder('Email');
|
||||||
this.nextButton = page.getByRole('button', { name: 'Next' });
|
this.nextButton = page.getByRole('button', { name: 'Next' });
|
||||||
this.loginWithPasswordButton = page.getByRole('button', { name: 'Use Password Instead' });
|
this.loginWithPasswordButton = page.getByRole('link', { name: 'Log in with a password instead' })
|
||||||
|
this.usePasswordInsteadButton = page.getByRole('button', { name: 'Use Password Instead' });
|
||||||
this.passwordTextBox = page.getByPlaceholder('Password');
|
this.passwordTextBox = page.getByPlaceholder('Password');
|
||||||
this.paypalLoginButton = page.getByRole('button', { name: 'Log In', exact: true });
|
this.paypalLoginButton = page.getByRole('button', { name: 'Log In', exact: true });
|
||||||
this.completePurchaseButton = page.getByRole('button', { name: 'Pay $' });
|
this.completePurchaseButton = page.getByTestId('submit-button-initial')
|
||||||
|
this.payButton = page.getByRole('button', { name: 'Pay $' });
|
||||||
}
|
}
|
||||||
|
|
||||||
async completePaypalPurchase(paymentDetails: IPaymentDetails){
|
async completePaypalPurchase(paymentDetails: IPaymentDetails){
|
||||||
if (!await this.loginWithPasswordButton.isVisible()) {
|
// Wait for the PayPal login page to load
|
||||||
|
await this.page.waitForFunction(() => window.location.href.includes('sandbox.paypal.com'), null, { timeout: 10000 });
|
||||||
|
|
||||||
|
// handle flow with and without the "Log in with a password instead" link
|
||||||
|
if (await this.loginWithPasswordButton.isVisible()) {
|
||||||
|
await this.loginWithPasswordButton.click();
|
||||||
|
await this.passwordTextBox.fill(paymentDetails.password!);
|
||||||
|
await this.paypalLoginButton.click();
|
||||||
|
await this.completePurchaseButton.click();
|
||||||
|
} else {
|
||||||
await this.usernameTextBox.fill(paymentDetails.username!);
|
await this.usernameTextBox.fill(paymentDetails.username!);
|
||||||
await this.nextButton.click();
|
await this.nextButton.click();
|
||||||
|
await this.usePasswordInsteadButton.click();
|
||||||
|
await this.passwordTextBox.fill(paymentDetails.password!);
|
||||||
|
await this.paypalLoginButton.click();
|
||||||
|
await this.payButton.click();
|
||||||
}
|
}
|
||||||
await this.loginWithPasswordButton.click();
|
|
||||||
await this.passwordTextBox.fill(paymentDetails.password!);
|
|
||||||
await this.paypalLoginButton.click();
|
|
||||||
await this.completePurchaseButton.click();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue