This repository has been archived on 2025-04-22. You can view files and clone it, but cannot push or open issues or pull requests.
hlk_autotest/tests/setup/staff_auth.setup.ts
LingandRX 6517e4192c feat: 初始化慧来客自动化测试项目
- 添加项目配置文件和环境变量设置
- 创建测试用例目录结构和命名规范
- 实现基础测试 fixture 和页面对象模型
- 添加示例测试用例和数据生成器
- 配置 playwright 和 gitignore 文件
2024-12-22 19:18:27 +08:00

32 lines
1.4 KiB
TypeScript

import { test as setup, expect } from "@playwright/test";
const authFileArray = [".auth/user_1.json", ".auth/user_2.json"];
const employee = [
{
phone: process.env.staff1_account,
password: process.env.staff1_password,
},
{
phone: process.env.staff2_account,
password: process.env.staff2_password,
},
];
setup.describe("员工登录", () => {
for (let i = 0; i < 2; i++) {
setup(`门店员工登录_${i}`, async ({ page }) => {
const baseUrl = process.env.BASE_URL;
const $phone = page.getByRole("textbox", { name: "请输入您的手机号码" });
const $password = page.getByRole("textbox", { name: "请输入登录密码" });
const $login = page.getByRole("button", { name: /登\s录/ });
await page.goto(baseUrl);
await $phone.fill(employee[i].phone);
const checkPhone = page.locator(".ant-row", { has: $phone }).locator(".pass_svg");
await expect(checkPhone).toBeVisible();
await $password.fill(employee[i].password);
await page.getByLabel("请同意慧来客隐私政策和用户协议").check();
await $login.click();
await expect(page.getByRole("button", { name: /开\s单/ })).toBeEnabled();
await page.context().storageState({ path: authFileArray[i] });
});
}
});