Skip to content

Commit

Permalink
Directly select the iframe using frameLocator when filling cvc
Browse files Browse the repository at this point in the history
'Select your bank' field has been renamed
Replace page.locator with the proper getByRole functions
  • Loading branch information
Kwok He Chu committed Dec 19, 2023
1 parent c948a66 commit c25d48f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
21 changes: 12 additions & 9 deletions tests/advanced-checkout/ideal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,24 @@ test('iDEAL', async ({ page }) => {

// Click "Continue to checkout"
await page.getByRole('link', { name: 'Continue to checkout' }).click();
await expect(page.getByTitle('Select your bank')).toBeVisible();

// Click "Select your bank"
await page.getByTitle('Select your bank').click();
const selectButton = await page.getByTitle('Select your bank');
if (await selectButton.count() === 0) {
// Click radio button for > Adyen-Web 5.53.x or higher
await page.getByPlaceholder('Search...').click();
} else {
await selectButton.click();
}

// Choose "Test Issuer"
const element = page.locator('input[aria-autocomplete="list"]');
await element.type('Test Issuer');
await element.press('Enter');
await page.getByText('Test Issuer', { exact: true }).click();

// Click "Continue to Test Issuer"
await page.click('text="Continue to Test Issuer"');
await page.getByRole('button', { name: 'Continue to Test Issuer' }).click();
await expect(page.locator('text="iDEAL Issuer Simulation"')).toBeVisible();

// Click "Continue"
await page.click('text="Continue"');
await expect(page.locator('text="Return Home"')).toBeVisible();
// Click "Continue"
await page.getByRole('button', { name: 'Continue' }).click();
await page.getByRole('link', { name: 'Return Home' }).click();
});
23 changes: 13 additions & 10 deletions tests/checkout/ideal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,27 @@ test('iDEAL', async ({ page }) => {
// Select "iDEAL"
await page.getByRole('link', { name: 'iDEAL' }).click();
await expect(page.locator('text="Cart"')).toBeVisible();

// Click "Continue to checkout"
await page.getByRole('link', { name: 'Continue to checkout' }).click();
await expect(page.getByTitle('Select your bank')).toBeVisible();

// Click "Select your bank"
await page.getByTitle('Select your bank').click();

// Choose "Test Issuer"
const element = page.locator('input[aria-autocomplete="list"]');
await element.type('Test Issuer');
await element.press('Enter');

const selectButton = await page.getByTitle('Select your bank');
if (await selectButton.count() === 0) {
// Click radio button for > Adyen-Web 5.53.x or higher
await page.getByPlaceholder('Search...').click();
} else {
await selectButton.click();
}

// Click "Continue to Test Issuer"
await page.click('text="Continue to Test Issuer"');
await page.getByRole('button', { name: 'Continue to Test Issuer' }).click();
await expect(page.locator('text="iDEAL Issuer Simulation"')).toBeVisible();

// Click "Continue"
await page.click('text="Continue"');
await expect(page.locator('text="Return Home"')).toBeVisible();
// Click "Continue"
await page.getByRole('button', { name: 'Continue' }).click();
await page.getByRole('link', { name: 'Return Home' }).click();
});
5 changes: 2 additions & 3 deletions tests/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ module.exports = {
// Find iframe and fill "Expiry date" field
const expiryDateFrame = await page.frameLocator('iframe[title*="expiry date"]');
await expiryDateFrame.getByPlaceholder('MM/YY').fill(expiryDate);

// Find iframe and fill "CVC" field
const cvcFrame = await page.getByRole('region[name="Credit or debit card"i]').frameLocator('iframe[title*="security code"]');

const cvcFrame = await page.frameLocator('iframe[title="Iframe for security code"]');
await cvcFrame.getByPlaceholder('3 digits').fill(cvc);

// Find and fill "Name on card" field - Note: this field is not contained within an iframe
Expand Down

0 comments on commit c25d48f

Please sign in to comment.