error-context.md 5.9 KB

Instructions

  • Following Playwright test failed.
  • Explain why, be concise, respect Playwright best practices.
  • Provide a snippet of code with the fix, if possible.

Test info

  • Name: app.spec.js >> 登录模块 >> TC-001: 正常登录
  • Location: e2e/app.spec.js:7:3

Error details

Error: page.goto: net::ERR_ADDRESS_UNREACHABLE at https://ajy.danclub.cn/
Call log:
  - navigating to "https://ajy.danclub.cn/", waiting until "load"

Page snapshot

- generic [ref=e3]:
  - generic [ref=e6]:
    - heading "This site can’t be reached" [level=1] [ref=e7]
    - paragraph [ref=e8]:
      - strong [ref=e9]: https://ajy.danclub.cn/
      - text: is unreachable.
    - generic [ref=e10]: ERR_ADDRESS_UNREACHABLE
  - button "Reload" [ref=e13] [cursor=pointer]

Test source

  1   | const { test, expect } = require('@playwright/test');
  2   | 
  3   | const BASE_URL = 'https://ajy.danclub.cn';
  4   | const TEST_ADMIN = { username: 'admin', password: 'admin123' };
  5   | 
  6   | test.describe('登录模块', () => {
  7   |   test('TC-001: 正常登录', async ({ page }) => {
> 8   |     await page.goto(BASE_URL);
      |                ^ Error: page.goto: net::ERR_ADDRESS_UNREACHABLE at https://ajy.danclub.cn/
  9   |     await page.waitForLoadState('networkidle');
  10  |     await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
  11  |     await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
  12  |     await page.getByRole('button', { name: '登 录' }).click();
  13  |     await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
  14  |   });
  15  | 
  16  |   test('TC-002: 用户名为空验证', async ({ page }) => {
  17  |     await page.goto(BASE_URL);
  18  |     await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
  19  |     await page.getByRole('button', { name: '登 录' }).click();
  20  |     await expect(page.getByText('请输入用户名')).toBeVisible();
  21  |   });
  22  | 
  23  |   test('TC-003: 密码为空验证', async ({ page }) => {
  24  |     await page.goto(BASE_URL);
  25  |     await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
  26  |     await page.getByRole('button', { name: '登 录' }).click();
  27  |     await expect(page.getByText('请输入密码')).toBeVisible();
  28  |   });
  29  | 
  30  |   test('TC-004: 错误账号登录', async ({ page }) => {
  31  |     await page.goto(BASE_URL);
  32  |     await page.getByPlaceholder('请输入用户名').fill('wronguser');
  33  |     await page.getByPlaceholder('请输入密码').fill('wrongpass');
  34  |     await page.getByRole('button', { name: '登 录' }).click();
  35  |     await page.waitForTimeout(2000);
  36  |     await expect(page.getByRole('button', { name: '登 录' })).toBeVisible();
  37  |   });
  38  | });
  39  | 
  40  | test.describe('账号管理模块', () => {
  41  |   test.beforeEach(async ({ page }) => {
  42  |     await page.goto(BASE_URL);
  43  |     await page.waitForLoadState('networkidle');
  44  |     await page.getByPlaceholder('请输入用户名').fill(TEST_ADMIN.username);
  45  |     await page.getByPlaceholder('请输入密码').fill(TEST_ADMIN.password);
  46  |     await page.getByRole('button', { name: '登 录' }).click();
  47  |     await page.waitForURL(`${BASE_URL}/#/user/app`, { timeout: 10000 });
  48  |   });
  49  | 
  50  |   test('TC-010: 查看账号管理页面', async ({ page }) => {
  51  |     await expect(page.locator('.el-table__body')).toBeVisible();
  52  |   });
  53  | 
  54  |   test('TC-011: 账号列表搜索-手机号', async ({ page }) => {
  55  |     await page.getByPlaceholder('请输入手机号').fill('138');
  56  |     await page.getByRole('button', { name: '搜索' }).click();
  57  |     await page.waitForTimeout(1000);
  58  |   });
  59  | 
  60  |   test('TC-012: 账号列表搜索-昵称', async ({ page }) => {
  61  |     await page.getByPlaceholder('请输入昵称').fill('管理员');
  62  |     await page.getByRole('button', { name: '搜索' }).click();
  63  |     await page.waitForTimeout(1000);
  64  |   });
  65  | 
  66  |   test('TC-013: 新增用户按钮存在', async ({ page }) => {
  67  |     await expect(page.getByRole('button', { name: '新增用户' })).toBeVisible();
  68  |   });
  69  | 
  70  |   test('TC-014: 编辑功能', async ({ page }) => {
  71  |     const editBtn = page.locator('button:has-text("编辑")').first();
  72  |     if (await editBtn.isVisible()) {
  73  |       await editBtn.click();
  74  |       await page.waitForTimeout(500);
  75  |     }
  76  |   });
  77  | 
  78  |   test('TC-015: 禁用功能', async ({ page }) => {
  79  |     const disableBtn = page.locator('button:has-text("禁用")').first();
  80  |     if (await disableBtn.isVisible()) {
  81  |       await disableBtn.click();
  82  |       await page.waitForTimeout(500);
  83  |     }
  84  |   });
  85  | 
  86  |   test('TC-017: 取消删除', async ({ page }) => {
  87  |     const deleteBtn = page.locator('button:has-text("删除")').first();
  88  |     if (await deleteBtn.isVisible()) {
  89  |       await deleteBtn.click();
  90  |       await page.waitForTimeout(500);
  91  |       const cancelBtn = page.getByRole('button', { name: '取消' });
  92  |       if (await cancelBtn.isVisible()) {
  93  |         await cancelBtn.click();
  94  |       }
  95  |     }
  96  |   });
  97  | 
  98  |   test('TC-017: 重置搜索条件', async ({ page }) => {
  99  |     await page.getByPlaceholder('请输入手机号').fill('测试');
  100 |     await page.getByRole('button', { name: '重置' }).click();
  101 |     await page.waitForTimeout(500);
  102 |   });
  103 | });
  104 | 
  105 | test.describe('穴位管理模块', () => {
  106 |   test.beforeEach(async ({ page }) => {
  107 |     await page.goto(BASE_URL);
  108 |     await page.waitForLoadState('networkidle');