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.
playwright-demo/tests/hlk/setup/hlk.setup.js
rsgltzyd db0603dcfd
Some checks failed
Playwright Tests / test (push) Has been cancelled
init
2024-11-07 22:00:35 +08:00

22 lines
1.0 KiB
JavaScript

const { test: setup, expect } = require('@playwright/test');
const path = require('path');
const hlkAuthFile = path.join(process.cwd(), '.auth', 'hlk_admin.json');
setup('hlk总部管理员登录', async ({ page, baseURL }) => {
const $account = page.getByRole('textbox', { name: '请输入您的手机号码' });
const $password = page.getByRole('textbox', { name: '请输入登录密码' });
const $loginBtn = page.getByRole('button', { name: /登\s录/ });
const account = process.env.ACCOUNT;
const password = process.env.PASSWORD;
await page.goto(baseURL);
await $account.fill(account);
const phoneStatsIcon = page.locator('.ant-row', { has: $account }).locator('.pass_svg');
await $password.fill(password);
await page.getByLabel('请同意慧来客隐私政策和用户协议').check();
await expect(phoneStatsIcon).toBeVisible();
await $loginBtn.click();
await expect(page.getByRole('button', { name: /开\s单/ })).toBeVisible();
await page.context().storageState({ path: hlkAuthFile });
});