From 31915928f501f1032169b4d37526745f342394a6 Mon Sep 17 00:00:00 2001 From: mildred Date: Fri, 8 Mar 2024 23:37:28 +0100 Subject: [PATCH] Fix login, add encryptionPage, add DataProt Page --- src/page-objects/AD_EncryptionKeyPage.ts | 74 +++++++++++++++++ src/page-objects/COMM_DataProtectionPage.ts | 88 +++++++++++++++++++++ 2 files changed, 162 insertions(+) create mode 100644 src/page-objects/AD_EncryptionKeyPage.ts create mode 100644 src/page-objects/COMM_DataProtectionPage.ts diff --git a/src/page-objects/AD_EncryptionKeyPage.ts b/src/page-objects/AD_EncryptionKeyPage.ts new file mode 100644 index 0000000..e4245df --- /dev/null +++ b/src/page-objects/AD_EncryptionKeyPage.ts @@ -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; + } + } + +} \ No newline at end of file diff --git a/src/page-objects/COMM_DataProtectionPage.ts b/src/page-objects/COMM_DataProtectionPage.ts new file mode 100644 index 0000000..d07b020 --- /dev/null +++ b/src/page-objects/COMM_DataProtectionPage.ts @@ -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; + } + } + +} \ No newline at end of file