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/setup/zhb.setup.js
2024-11-07 20:36:40 +08:00

41 lines
1.6 KiB
JavaScript

const { test: setup, expect } = require('@playwright/test');
const path = require('path');
const zhbAuthFile = '.auth/zhb.json';
const zhbAdminAuthFile = '.auth/zhb_admin.json';
setup('zhb总部管理员登录', async ({ page, baseURL }) => {
const account = process.env.ZHB_ACCOUNT;
const password = process.env.ZHB_PASSWORD;
await page.goto(baseURL);
await page.getByText('账号登录').click();
await page.getByPlaceholder('用户名').fill(account);
await page.getByPlaceholder('密码', { exact: true }).fill(password);
await page.getByText('登录', { exact: true }).click();
await expect(page.getByText('演示一店')).toBeVisible();
await expect(page.getByText('演示二店')).toBeVisible();
await page.getByText('演示一店').click();
await expect(page.locator('#tab_main li').filter({ hasText: '营业' })).toBeVisible();
await page.context().storageState({ path: zhbAuthFile });
});
// setup('zhb管理页面登录', async ({ page }) => {
// const account = process.env.ZHB_ACCOUNT;
// const password = process.env.ZHB_PASSWORD;
// const baseURL = process.env.ZHB_ADMIN_URL;
// await page.goto(baseURL);
// await page.getByPlaceholder('账户').fill(account);
// await page.getByPlaceholder('密码').fill(password);
// await page.getByRole('button', { name: '登 录' }).click();
// await expect(page.locator('a').filter({ hasText: /^收银$/ })).toBeVisible();
// await page
// .locator('a')
// .filter({ hasText: /^顾客$/ })
// .click();
// await expect(page.getByText('顾客概要分析')).toBeVisible();
// await page.context().storageState({ path: zhbAdminAuthFile });
// });