fix: handle missing error message elements gracefully

This commit is contained in:
张翔
2026-03-06 18:25:10 +08:00
parent ceec57f864
commit e112c75001
+5 -2
View File
@@ -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> {