Skip to content

Commit

Permalink
feat: add contact form page object and other corresponding locator ad…
Browse files Browse the repository at this point in the history
…dings
  • Loading branch information
frobel committed Jan 30, 2025
1 parent b58761b commit 5f81aef
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/page-objects/StorefrontPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { SearchSuggest } from './storefront/SearchSuggest';
import { CustomRegister } from './storefront/CustomRegister';
import { CheckoutOrderEdit } from './storefront/CheckoutOrderEdit';
import { AccountAddressCreate } from './storefront/AccountAddresssCreate';
import { ContactForm } from './storefront/ContactForm';

export interface StorefrontPageTypes {
StorefrontHome: Home;
Expand All @@ -43,6 +44,7 @@ export interface StorefrontPageTypes {
StorefrontSearchSuggest: SearchSuggest;
StorefrontCustomRegister: CustomRegister;
StorefrontCheckoutOrderEdit: CheckoutOrderEdit;
StorefrontContactForm: ContactForm;
}

export const StorefrontPageObjects = {
Expand All @@ -66,6 +68,7 @@ export const StorefrontPageObjects = {
SearchSuggest,
CustomRegister,
CheckoutOrderEdit,
ContactForm,
}

export const test = base.extend<FixtureTypes>({
Expand Down Expand Up @@ -144,10 +147,13 @@ export const test = base.extend<FixtureTypes>({

StorefrontCustomRegister: async ({ StorefrontPage }, use) => {
await use(new CustomRegister(StorefrontPage));

},

StorefrontCheckoutOrderEdit: async ({ StorefrontPage }, use) => {
await use(new CheckoutOrderEdit(StorefrontPage));
},

StorefrontContactForm: async ({ StorefrontPage }, use) => {
await use(new ContactForm(StorefrontPage));
},
});
52 changes: 52 additions & 0 deletions src/page-objects/storefront/ContactForm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import type { Page, Locator } from '@playwright/test';
import type { PageObject } from '../../types/PageObject';
import { Home } from './Home';

export class ContactForm extends Home implements PageObject {
public readonly contactModal: Locator;
public readonly contactSuccessModal: Locator;
public readonly salutationSelect: Locator;
public readonly firstNameInput: Locator;
public readonly lastNameInput: Locator;
public readonly emailInput: Locator;
public readonly phoneInput: Locator;
public readonly subjectInput: Locator;
public readonly commentInput: Locator;
public readonly privacyPolicyCheckbox: Locator;
public readonly submitButton: Locator;
public readonly contactSuccessMessage: Locator;
public readonly cardTitle: Locator;

/**
* Captcha locators
*/
public readonly basicCaptcha: Locator;
public readonly basicCaptchaImage: Locator;
public readonly basicCaptchaRefreshButton: Locator;
public readonly basicCaptchaInput: Locator;

constructor(public readonly page: Page) {
super(page);
this.contactModal = this.page.getByRole('dialog').filter({ has: this.page.getByLabel('Contact', { exact: true }) });
this.salutationSelect = this.contactModal.getByLabel('Salutation*');
this.firstNameInput = this.contactModal.getByLabel('First name*');
this.lastNameInput = this.contactModal.getByLabel('Last name*');
this.emailInput = this.contactModal.getByLabel('Your email address*');
this.phoneInput = this.contactModal.getByLabel('Phone*');
this.subjectInput = this.contactModal.getByLabel('Subject*');
this.commentInput = this.contactModal.getByLabel('Comment*');
this.privacyPolicyCheckbox = this.contactModal.getByRole('checkbox', { name: 'By selecting continue you confirm that you have read and agree to our' });
this.submitButton = this.contactModal.getByRole('button', { name: 'Submit' });
this.contactSuccessModal = this.page.getByRole('dialog').filter({ has: this.page.locator('.confirm-message') });
this.contactSuccessMessage = this.contactSuccessModal.locator('.confirm-message');
this.cardTitle = this.contactModal.locator('.card-title');
this.basicCaptcha = this.contactModal.locator('.basic-captcha');
this.basicCaptchaImage = this.basicCaptcha.locator('img');
this.basicCaptchaRefreshButton = this.basicCaptcha.locator('.basic-captcha-content-refresh-icon');
this.basicCaptchaInput = this.basicCaptcha.locator('input[name="shopware_basic_captcha_confirm"]');
}

url() {
return new Error('Function not implemented, because it is a modal page object').message;
}
}
3 changes: 3 additions & 0 deletions src/page-objects/storefront/Home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export class Home implements PageObject {
public readonly consentDialog: Locator;
public readonly consentDialogTechnicallyRequiredCheckbox: Locator;
public readonly consentDialogStatisticsCheckbox: Locator;
public readonly contactFormLink: Locator;

/**
* @deprecated Use 'consentDialogMarketingCheckbox' instead
*/
Expand Down Expand Up @@ -63,6 +65,7 @@ export class Home implements PageObject {
exact: true,
});
this.offcanvasBackdrop = page.locator('.offcanvas-backdrop');
this.contactFormLink = this.page.getByRole('listitem').getByTitle('Contact form', { exact: true });
}

async getMenuItemByCategoryName(categoryName: string): Promise<Record<string, Locator>> {
Expand Down

0 comments on commit 5f81aef

Please sign in to comment.