fix: 修正Playwright登录页选择器 - 使用实际placeholder '账号'/'密码'
This commit is contained in:
@@ -13,8 +13,21 @@ export class LoginPage {
|
||||
}
|
||||
|
||||
async login(username: string, password: string) {
|
||||
await this.page.fill('input[placeholder*="用户名"], input[placeholder*="账号"]', username);
|
||||
await this.page.fill('input[placeholder*="密码"]', password);
|
||||
// Actual placeholders from login.vue: "账号" and "密码"
|
||||
await this.page.fill('input[placeholder="账号"]', username);
|
||||
await this.page.fill('input[placeholder="密码"]', password);
|
||||
// Check for tenant selection if exists
|
||||
const tenantSelect = this.page.locator('.el-select__wrapper, input[placeholder="请选择医疗机构"]').first();
|
||||
if (await tenantSelect.isVisible().catch(() => false)) {
|
||||
await tenantSelect.click();
|
||||
await this.page.waitForTimeout(500);
|
||||
// Select first option
|
||||
const firstOption = this.page.locator('.el-select-dropdown__item, .el-option').first();
|
||||
if (await firstOption.isVisible().catch(() => false)) {
|
||||
await firstOption.click();
|
||||
await this.page.waitForTimeout(500);
|
||||
}
|
||||
}
|
||||
await this.page.click('button:has-text("登录")');
|
||||
await this.page.waitForLoadState('networkidle');
|
||||
}
|
||||
@@ -28,6 +41,6 @@ export class LoginPage {
|
||||
}
|
||||
|
||||
async expectOnLoginPage() {
|
||||
await expect(this.page.locator('input[placeholder*="用户名"], input[placeholder*="账号"]')).toBeVisible();
|
||||
await expect(this.page.locator('input[placeholder="账号"]')).toBeVisible();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user