diff --git a/src/page-objects/US_ViewMyCredentialsPage.ts b/src/page-objects/US_ViewMyCredentialsPage.ts index 8b1fd81..fbd049e 100644 --- a/src/page-objects/US_ViewMyCredentialsPage.ts +++ b/src/page-objects/US_ViewMyCredentialsPage.ts @@ -89,31 +89,48 @@ export class ViewMyCredentialsPage { async gotoViewEnabledCredentialPage(type: string) { - // Find the row that has the specified type and status 'Enabled' - const row = this.page.locator(`tr:has(td:nth-child(1):has-text("${type}"), td:nth-child(4):has-text("Enabled"))`); + let status = '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 - if (await row.count() > 0) { - // Find the view credential button within the row and click it - await row.locator('i.bi.bi-eye').click(); + if (await statusFilteredRows.count() > 0) { + // Click to view the credential + await statusFilteredRows.first().locator('i.bi.bi-eye').click(); } 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 { + + let status = 'Enabled'; - // Find the row that has the specified type and 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 - if (await row.count() > 0) { + if (await statusFilteredRows.count() > 0) { return true; } 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; } - } + } } \ No newline at end of file diff --git a/tests/03-COMM-templatesAndDataFiles.spec.ts b/tests/03-COMM-templatesAndDataFiles.spec.ts index 984ef5c..e77ed90 100644 --- a/tests/03-COMM-templatesAndDataFiles.spec.ts +++ b/tests/03-COMM-templatesAndDataFiles.spec.ts @@ -293,7 +293,7 @@ test.describe('USER Credentials Section Tests', () => { * 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 const credentialStatus = "Enabled" await gotoViewEnabledCredential(page, SCHEMA_TYPE_FVC);