Fix login, add encryptionPage, add DataProt Page

This commit is contained in:
mildred 2024-03-08 23:37:28 +01:00
parent 65641c0684
commit 31915928f5
2 changed files with 162 additions and 0 deletions

View File

@ -0,0 +1,74 @@
import { type Page, type Locator } from '@playwright/test';
export class EncryptionKeyPage {
readonly page: Page;
readonly primaryTitle: Locator
readonly secondaryTitle: Locator
readonly keyForEncryption: Locator
readonly saveButton: Locator
public constructor(page: Page) {
this.page = page;
this.page = page;
this.primaryTitle = page.getByRole('heading', { name: 'Encryption Key' });
this.secondaryTitle = page.getByRole('heading', { name: 'Encryption Key' });
this.keyForEncryption = page.getByPlaceholder('Key for encrypt the secrets');
this.saveButton = page.getByRole('button', { name: 'Save' });
}
async getPrimaryTitle() {
try {
return await this.primaryTitle.innerText();
} catch (error) {
console.error("Failed to get primary title:", error);
throw error;
}
}
async getSecondaryTitle() {
try {
return await this.secondaryTitle.innerText();
} catch (error) {
console.error("Failed to get secondary title:", error);
throw error;
}
}
async getKeyForEncryption() {
try {
return this.keyForEncryption;
} catch (error) {
console.error("Failed to get key for encryption:", error);
throw error;
}
}
async getSaveButton() {
try {
return this.saveButton;
} catch (error) {
console.error("Failed to get save button:", error);
throw error;
}
}
async enterKey(key: string) {
try {
(await this.getKeyForEncryption()).click();
(await this.getKeyForEncryption()).fill(key);
} catch (error) {
console.error('Failed to enter the encryption key:', error);
throw error;
}
}
async clickSaveButton() {
try {
(await this.getSaveButton()).click();
} catch (error) {
console.error('Failed to click save button:', error);
throw error;
}
}
}

View File

@ -0,0 +1,88 @@
import { type Page, type Locator } from '@playwright/test';
export class DataProtectionPage {
readonly page: Page;
readonly primaryTitle: Locator
readonly secondaryTitle: Locator
readonly acceptPrivacyCheckBox: Locator
readonly acceptLegalCheckBox: Locator
readonly acceptCookiesCheckBox: Locator
readonly confirmButton: Locator
public constructor(page: Page) {
this.page = page;
this.primaryTitle = page.getByRole('heading', { name: 'Data protection' });
this.secondaryTitle = page.getByRole('heading', { name: ' Terms and Conditions' });
this.acceptPrivacyCheckBox = page.locator('#id_accept_privacy');
this.acceptLegalCheckBox = page.locator('#id_accept_legal');
this.acceptCookiesCheckBox = page.locator('#id_accept_cookies');
this.confirmButton = page.getByRole('link', { name: 'Confirm' });
}
async getPrimaryTitle() {
try {
return await this.primaryTitle.innerText();
} catch (error) {
console.error("Failed to get primary title:", error);
throw error;
}
}
async getSecondaryTitle() {
try {
return await this.secondaryTitle.innerText();
} catch (error) {
console.error("Failed to get secondary title:", error);
throw error;
}
}
async checkAcceptPrivacyCheckBox() {
try {
return this.acceptPrivacyCheckBox.check();
} catch (error) {
console.error("Failed to check privacy box:", error);
throw error;
}
}
async checkAcceptCookiesCheckBox() {
try {
return this.acceptCookiesCheckBox.check();
} catch (error) {
console.error("Failed to check cookies box:", error);
throw error;
}
}
async checkAcceptLegalCheckBox() {
try {
return this.acceptLegalCheckBox.check();
} catch (error) {
console.error("Failed to check legal box:", error);
throw error;
}
}
async getConfirmButton() {
try {
return this.confirmButton;
} catch (error) {
console.error("Failed to get save button:", error);
throw error;
}
}
async clickConfirmButton() {
try {
(await this.getConfirmButton()).click();
} catch (error) {
console.error('Failed to click save button:', error);
throw error;
}
}
}