|
@@ -72,23 +72,37 @@ export class DisabilityPersonManagementPage {
|
|
|
province: string;
|
|
province: string;
|
|
|
city: string;
|
|
city: string;
|
|
|
}) {
|
|
}) {
|
|
|
- // 等待表单出现 - 使用正确的 form ID
|
|
|
|
|
|
|
+ // 等待表单出现
|
|
|
await this.page.waitForSelector('form#create-form', { state: 'visible', timeout: 5000 });
|
|
await this.page.waitForSelector('form#create-form', { state: 'visible', timeout: 5000 });
|
|
|
|
|
|
|
|
// 填写基本信息
|
|
// 填写基本信息
|
|
|
await this.page.getByLabel('姓名 *').fill(data.name);
|
|
await this.page.getByLabel('姓名 *').fill(data.name);
|
|
|
- await this.page.getByLabel('性别 *').selectOption(data.gender);
|
|
|
|
|
|
|
+ await this.selectRadixOption('性别 *', data.gender);
|
|
|
await this.page.getByLabel('身份证号 *').fill(data.idCard);
|
|
await this.page.getByLabel('身份证号 *').fill(data.idCard);
|
|
|
await this.page.getByLabel('残疾证号 *').fill(data.disabilityId);
|
|
await this.page.getByLabel('残疾证号 *').fill(data.disabilityId);
|
|
|
- await this.page.getByLabel('残疾类型 *').selectOption(data.disabilityType);
|
|
|
|
|
- await this.page.getByLabel('残疾等级 *').selectOption(data.disabilityLevel);
|
|
|
|
|
|
|
+ await this.selectRadixOption('残疾类型 *', data.disabilityType);
|
|
|
|
|
+ await this.selectRadixOption('残疾等级 *', data.disabilityLevel);
|
|
|
await this.page.getByLabel('联系电话 *').fill(data.phone);
|
|
await this.page.getByLabel('联系电话 *').fill(data.phone);
|
|
|
await this.page.getByLabel('身份证地址 *').fill(data.idAddress);
|
|
await this.page.getByLabel('身份证地址 *').fill(data.idAddress);
|
|
|
|
|
|
|
|
- // 居住地址 - 使用省份选择
|
|
|
|
|
- await this.page.locator('select[name="province"]').selectOption(data.province);
|
|
|
|
|
|
|
+ // 居住地址 - 使用 Radix UI Select
|
|
|
|
|
+ await this.selectRadixOption('省份 *', data.province);
|
|
|
await this.page.waitForTimeout(500); // 等待城市加载
|
|
await this.page.waitForTimeout(500); // 等待城市加载
|
|
|
- await this.page.locator('select[name="city"]').selectOption(data.city);
|
|
|
|
|
|
|
+ await this.selectRadixOption('城市', data.city);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 公共方法:处理 Radix UI Select 组件
|
|
|
|
|
+ // 方法:点击 combobox 打开菜单,然后点击选项
|
|
|
|
|
+ async selectRadixOption(label: string, value: string) {
|
|
|
|
|
+ const combobox = this.page.getByRole('combobox', { name: label });
|
|
|
|
|
+
|
|
|
|
|
+ // 点击 combobox 打开菜单
|
|
|
|
|
+ await combobox.click({ timeout: 2000 });
|
|
|
|
|
+
|
|
|
|
|
+ // 点击选项 - 使用 .first() 处理多个匹配
|
|
|
|
|
+ const option = this.page.getByRole('option', { name: value }).first();
|
|
|
|
|
+ await option.click({ timeout: 3000 });
|
|
|
|
|
+ console.log(` ✓ ${label} 选中: ${value}`);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async submitForm() {
|
|
async submitForm() {
|
|
@@ -123,7 +137,7 @@ export class DisabilityPersonManagementPage {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// 点击创建按钮
|
|
// 点击创建按钮
|
|
|
- const submitButton = this.page.locator('form#create-form button[type="submit"]');
|
|
|
|
|
|
|
+ const submitButton = this.page.getByRole('button', { name: '创建' });
|
|
|
await submitButton.click();
|
|
await submitButton.click();
|
|
|
|
|
|
|
|
// 等待网络请求完成
|
|
// 等待网络请求完成
|