UNPKG

external-services-automation

Version:

External services automation library for Playwright and Cucumber

65 lines (64 loc) 2.54 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RegisterPage = void 0; const test_1 = require("@playwright/test"); class RegisterPage { constructor(page) { this.page = page; this.firstNameInput = page.locator('input[name="p_first_name"]'); this.lastNameInput = page.locator('input[name="p_last_name"]'); this.emailInput = page.locator('input[name="p_email"]'); this.marketingOptInCheckbox = page.locator('input[name="p_kp_usr_is_marketing_opt_in"]'); this.acceptPoliciesCheckbox = page.locator('input[name="p_has_clickwrap_accepted"]'); this.createAccountButton = page.locator('//span[contains(text(), "account")]/parent::button'); } async navigate() { await this.page.goto('/auth/register'); await this.isOnRegisterPage(); } async enterFirstName(firstName) { await this.firstNameInput.fill(firstName); } async enterLastName(lastName) { await this.lastNameInput.fill(lastName); } async enterEmail(email) { await this.emailInput.fill(email); } async checkMarketingOptIn() { await this.marketingOptInCheckbox.check(); } async checkAcceptPolicies() { await this.acceptPoliciesCheckbox.check(); } async clickCreateAccount() { await this.createAccountButton.click(); } async fillAndSubmitCreateAccountForm(firstName, lastName, email, acceptMarketing = false) { await this.enterFirstName(firstName); await this.enterLastName(lastName); await this.enterEmail(email); if (acceptMarketing) { await this.checkMarketingOptIn(); } const checkboxCount = await this.acceptPoliciesCheckbox.count(); if (checkboxCount > 0) { try { await this.checkAcceptPolicies(); } catch (error) { // Ignore if checkbox is not interactable } } await this.clickCreateAccount(); } async isOnRegisterPage() { await (0, test_1.expect)(this.firstNameInput).toBeVisible(); await (0, test_1.expect)(this.lastNameInput).toBeVisible(); await (0, test_1.expect)(this.emailInput).toBeVisible(); await (0, test_1.expect)(this.marketingOptInCheckbox).toBeVisible(); // await expect(this.acceptPoliciesCheckbox).toBeVisible(); await (0, test_1.expect)(this.createAccountButton).toBeVisible(); } } exports.RegisterPage = RegisterPage;