From b3c3411a3736357cf0ef5c9a568dcbb519cec258 Mon Sep 17 00:00:00 2001 From: maguire-arman Date: Thu, 15 May 2025 10:47:17 -0400 Subject: [PATCH] Fixes service location selection Corrects an issue where the service location wasn't being selected properly in certain scenarios. Specifically, it ensures the 'Enter Service Address' button is clicked only when the address text box is not visible. It also removes the unnecessary 'saveAddressButton' click. --- playwright-tests/pages/ServiceLocationPage.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/playwright-tests/pages/ServiceLocationPage.ts b/playwright-tests/pages/ServiceLocationPage.ts index 49577e963..375566c04 100644 --- a/playwright-tests/pages/ServiceLocationPage.ts +++ b/playwright-tests/pages/ServiceLocationPage.ts @@ -36,7 +36,6 @@ export class ServiceLocationPage extends BasePage { readonly zipCodeTextBox: Locator; readonly vehicleProtectedYesButton: Locator; readonly vehicleProtectedNoButton: Locator; - readonly saveAddressButton: Locator; readonly repeatedClicksModalCloseButton: Locator; url = process.env['BASE_URL']! + '/fmg/?fmgPage=service-location'; @@ -49,7 +48,7 @@ export class ServiceLocationPage extends BasePage { // Initial selection this.inShopButton = this.page.getByText(/In-shop/); - this.mobileButton = this.page.getByText(/Mobile/); + this.mobileButton = this.page.getByText(/Mobile/).nth(0); this.dropOffButton = this.page.getByText(/Drop-off/); this.RecalWarningMessage1 = this.page.getByText(/We're not able to provide mobile service/); this.RecalWarningMessage2 = this.page.getByText(/advanced safety system recalibration needs to be done in our shop./); @@ -72,7 +71,6 @@ export class ServiceLocationPage extends BasePage { this.zipCodeTextBox = this.page.getByRole('textbox', { name: 'Zip code' }); this.vehicleProtectedYesButton = this.page.locator('label').filter({ hasText: 'Yes' }).locator('div'); this.vehicleProtectedNoButton = this.page.locator('label').filter({ hasText: 'No' }).locator('div'); - this.saveAddressButton = this.page.getByRole('button', { name: 'Continue' }) this.repeatedClicksModalCloseButton = this.page.locator('.QSISlider').locator('img[src*=\'close\']'); } @@ -120,7 +118,9 @@ export class ServiceLocationPage extends BasePage { const { appointmentDetails, customerDetails } = testData; if (appointmentDetails?.serviceAddress) { await this.mobileButton.click(); - await this.enterServiceAddressButton.click(); + if (!(await this.serviceAddressTextBox.isVisible())) { + await this.enterServiceAddressButton.click(); + } await this.addressForm.populateAddress({ address: appointmentDetails.serviceAddress! }); if (await this.repeatedClicksModalCloseButton.isVisible()) { await this.repeatedClicksModalCloseButton.click(); @@ -134,7 +134,6 @@ export class ServiceLocationPage extends BasePage { { await this.mockScheduleResponseForEarlyBird(customerDetails!); } - await this.saveAddressButton.click(); } else { console.error('ServiceLocationPage >> Please supply an address') }