change strategy to find the enabled credential

This commit is contained in:
mildred 2024-03-08 19:13:55 +01:00
parent 2da6a2d02f
commit 65641c0684
2 changed files with 29 additions and 12 deletions

View File

@ -89,31 +89,48 @@ export class ViewMyCredentialsPage {
async gotoViewEnabledCredentialPage(type: string) { async gotoViewEnabledCredentialPage(type: string) {
// Find the row that has the specified type and status 'Enabled' let status = 'Enabled';
const row = this.page.locator(`tr:has(td:nth-child(1):has-text("${type}"), td:nth-child(4):has-text("Enabled"))`); // Locator for all rows
const rowLocator = this.page.locator('tr');
// Rows with the first column having the specified type
const typeFilteredRows = rowLocator.filter({ hasText: type });
// Rows with the fourth column having the specified status
const statusFilteredRows = typeFilteredRows.filter({ hasText: status });
// only the rows matching both criteria
// Check if the row exists // Check if the row exists
if (await row.count() > 0) { if (await statusFilteredRows.count() > 0) {
// Find the view credential button within the row and click it // Click to view the credential
await row.locator('i.bi.bi-eye').click(); await statusFilteredRows.first().locator('i.bi.bi-eye').click();
} else { } else {
console.log(`No row found with type '${type}' and status 'Enabled'.`); console.log(`No row found with type '${type}' and status '${status}'.`);
} }
} }
async enabledCredentialExistInMyCredentials(type: string): Promise<boolean> { async enabledCredentialExistInMyCredentials(type: string): Promise<boolean> {
let status = 'Enabled';
// Find the row that has the specified type and status 'Enabled' // Locator for all rows
const row = this.page.locator(`tr:has(td:nth-child(1):has-text("${type}"), td:nth-child(4):has-text("Enabled"))`); const rowLocator = this.page.locator('tr');
// Rows with the first column having the specified type
const typeFilteredRows = rowLocator.filter({ hasText: type });
// Rows with the fourth column having the specified status
const statusFilteredRows = typeFilteredRows.filter({ hasText: status });
// only the rows matching both criteria
// Check if the row exists // Check if the row exists
if (await row.count() > 0) { if (await statusFilteredRows.count() > 0) {
return true; return true;
} else { } else {
console.log(`No row found with type '${type}' and status 'Enabled'.`); console.log(`No row found with type '${type}' and status '${status}'.`);
return false; return false;
} }
}
}
} }

View File

@ -293,7 +293,7 @@ test.describe('USER Credentials Section Tests', () => {
* Check the fields displayed when user click "View" Credential * Check the fields displayed when user click "View" Credential
*/ */
test.skip('USER Credentials -> My Credentials -> View enabled Financial Vulnerability Credential', async ({ page }) => { test('USER Credentials -> My Credentials -> View enabled Financial Vulnerability Credential', async ({ page }) => {
// View the Financial Vulnerabilty Credential in status 'Enabled' for the user // View the Financial Vulnerabilty Credential in status 'Enabled' for the user
const credentialStatus = "Enabled" const credentialStatus = "Enabled"
await gotoViewEnabledCredential(page, SCHEMA_TYPE_FVC); await gotoViewEnabledCredential(page, SCHEMA_TYPE_FVC);