This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
IdHub_E2E_testing/src/page-objects/US_AddIdentityPage.ts

88 lines
2.2 KiB
TypeScript

import { Page, Locator, expect } from "@playwright/test"
export class AddIdentityPage {
readonly page: Page
readonly primaryTitle: Locator
readonly secondaryTitle: Locator
readonly label: Locator
readonly dropdownType: Locator
readonly saveButton: Locator
readonly cancelButton: Locator
public constructor(page: Page) {
this.page = page;
this.primaryTitle = this.page.getByRole('heading', { name: 'My wallet' })
this.secondaryTitle = this.page.getByRole('heading', { name: ' Add a new Identity (DID)' })
this.label = this.page.getByPlaceholder('Label')
this.dropdownType = this.page.getByLabel('Type')
this.saveButton = this.page.getByRole('button', { name: 'Save' })
this.cancelButton = this.page.getByRole('link', { name: 'Cancel' })
}
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 getDropdownType() {
try {
return this.dropdownType;
} catch (error) {
console.error("Failed to get dropdown DID Type value:", error);
throw error;
}
}
async getLabel() {
try {
return this.label;
} catch (error) {
console.error("Failed to get Label value:", error);
throw error;
}
}
async getSaveButton() {
try {
return this.saveButton;
} catch (error) {
console.error("Failed to get the 'Save' button:", error);
throw error;
}
}
async getCancelButton() {
try {
return this.cancelButton;
} catch (error) {
console.error("Failed to get the 'Cancel' button:", error);
throw error;
}
}
async addDid(label: string, didType: string) {
try {
(await this.getLabel()).fill(label);
(await this.getDropdownType()).selectOption({ label: didType });
(await this.getSaveButton()).click();
} catch (error) {
console.error("Failed adding new did: ", error);
throw error;
}
}
}