import { chromium } from '@playwright/test' const browser = await chromium.launch({ channel: 'msedge', headless: true }) const page = await browser.newPage({ viewport: { width: 1440, height: 900 } }) const errors = [] page.on('pageerror', (e) => errors.push('pageerror: ' + e.message)) page.on('console', (m) => { if (m.type() === 'error') errors.push('console: ' + m.text().slice(0, 200)) }) const userReqs = [] page.on('request', (r) => { if (r.url().includes('/api/admin/users')) userReqs.push(r.url()) }) await page.goto('http://localhost:5174/admin-vue/', { waitUntil: 'networkidle' }) await page.waitForTimeout(800) if (await page.locator('#loginUsername').isVisible().catch(() => false)) { await page.locator('#loginUsername').fill('admin') await page.locator('#loginPassword').fill('admin123') await page.locator('.btn-login').click() await page.waitForSelector('.admin-shell', { timeout: 25000 }).catch(() => {}) await page.waitForTimeout(1500) } await page.goto('http://localhost:5174/admin-vue/account/users', { waitUntil: 'domcontentloaded' }) await page.waitForTimeout(2200) const selects = page.locator('.users-filter-row .el-select') console.log('筛选行 el-select 数量:', await selects.count()) await selects.nth(1).click() await page.waitForTimeout(700) const items = page.locator('.el-select-dropdown__item:visible') console.log('选项:', JSON.stringify(await items.allTextContents())) await items.filter({ hasText: /^管理员$/ }).first().click() await page.waitForTimeout(1200) console.log('change 后请求:', JSON.stringify(userReqs.slice(-1))) await page.locator('.users-filter-row button.btn').first().click() await page.waitForTimeout(2500) console.log('点查询后请求:', JSON.stringify(userReqs.slice(-1))) console.log('选中显示:', (await selects.nth(1).textContent())?.trim()) console.log('最近 users 请求:', JSON.stringify(userReqs.slice(-2))) const roles = await page.locator('.table-scroll tbody tr td').nth(2).textContent().catch(() => '?') console.log('第一行角色:', roles?.trim()) await page.goto('http://localhost:5174/admin-vue/asin-center/skip-price', { waitUntil: 'domcontentloaded' }) await page.waitForTimeout(2000) await page.locator('.price-range-row input').first().fill('1.15') await page.locator('.skip-filter-row button.btn').first().click() await page.waitForTimeout(2500) console.log('errors:', JSON.stringify(errors)) await browser.close()