| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- import { test, expect } from '@playwright/test';
- test('银行名称搜索框验证', async ({ page }) => {
- console.log('1. 导航到银行名称页面...');
- await page.goto('http://localhost:8080/admin/bank-names', { waitUntil: 'networkidle' });
-
- console.log('2. 查找搜索框...');
- const searchInput = page.locator('input[placeholder*="搜索"], input[placeholder*="search"], input[type="search"]').first();
-
- const count = await searchInput.count();
- console.log('找到搜索框数量:', count);
-
- if (count === 0) {
- console.log('未找到搜索框,列出所有 input 元素...');
- const allInputs = await page.locator('input').all();
- for (let i = 0; i < Math.min(allInputs.length, 5); i++) {
- const input = allInputs[i];
- const placeholder = await input.getAttribute('placeholder');
- const type = await input.getAttribute('type');
- console.log('Input ' + (i + 1) + ': type=' + type + ', placeholder=' + placeholder);
- }
- test.skip(true, '未找到搜索框');
- return;
- }
-
- console.log('3. 输入中文"中国"...');
- await searchInput.fill('中国');
- await page.waitForTimeout(500);
-
- const beforeValue = await searchInput.inputValue();
- console.log('输入后的值:', beforeValue);
-
- console.log('4. 按 Enter 键...');
- await searchInput.press('Enter');
- await page.waitForTimeout(1000);
-
- const afterValue = await searchInput.inputValue();
- console.log('按 Enter 后的值:', afterValue);
-
- // 截图
- await page.screenshot({ path: '/mnt/code/188-179-template-6/search_verification.png' });
- console.log('截图已保存到 search_verification.png');
-
- // 验证
- expect(beforeValue).toBe('中国');
- expect(afterValue).toBe('中国');
- console.log('验证通过:搜索内容保持不变');
- });
|