fix: handle missing error message elements gracefully
This commit is contained in:
@@ -23,8 +23,11 @@ export class ContactPage extends BasePage {
|
||||
}
|
||||
|
||||
async getFormErrorMessage(): Promise<string> {
|
||||
const errorElement = await this.page.locator('[data-testid="error-message"]').first();
|
||||
return await errorElement.textContent() || '';
|
||||
const errorElement = await this.page.locator('[data-testid="error-message"]');
|
||||
if (await errorElement.count() > 0) {
|
||||
return await errorElement.first().textContent() || '';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
async getFormSuccessMessage(): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user