# -*- coding: utf-8 -*- """CHG-038 验证:KFZ 前端/后端弹窗分流 + 用户编辑表单开发方向下拉""" import io, sys from playwright.sync_api import sync_playwright sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') BASE = 'http://localhost:8088' with sync_playwright() as p: b = p.chromium.launch(channel='chrome', headless=True) page = b.new_page(viewport={'width': 1600, 'height': 1000}) page.goto(BASE, wait_until='domcontentloaded'); page.wait_for_timeout(2500) page.locator('input[placeholder="用户名"]').fill('admin') page.locator('input[placeholder="密码"]').fill('123456') page.locator('text="登录"').first.click(); page.wait_for_timeout(8000) # 1) 月报 6 月 page.goto(f'{BASE}/#/worktime/count', wait_until='domcontentloaded'); page.wait_for_timeout(8000) page.locator('.el-tabs__item:has-text("月报"):visible').first.click(); page.wait_for_timeout(5000) page.locator('button:has-text("上月"):visible').first.click(); page.wait_for_timeout(1000) page.locator('button:has-text("查询"):visible').first.click() page.wait_for_selector('tr:has-text("郭尚雨")', timeout=25000) page.wait_for_timeout(2000) def perf_shot(cname, tag, must, must_not): row = page.locator(f'tr:has-text("{cname}")').first row.locator('button:has-text("绩效")').first.click(); page.wait_for_timeout(5000) body = page.locator('body').inner_text() miss = [k for k in must if k not in body] bad = [k for k in must_not if k in body] page.screenshot(path=f'tmp/pw_chg038_{tag}.png', full_page=True) ok = 'PASS' if not miss and not bad else f'MISS:{miss} BAD:{bad}' print(f'[{tag}] {ok} 截图 tmp/pw_chg038_{tag}.png') closed = False for sel in ['.el-dialog__close', 'button:has-text("取 消")', 'button:has-text("取消")']: loc = page.locator(sel) if loc.count(): try: loc.first.click(); closed = True; break except Exception: pass if not closed: page.keyboard.press('Escape') page.wait_for_timeout(2000) # 郭尚雨=frontend:饱和度30%、无文档质量行、代码质量 flat perf_shot('郭尚雨', 'guoshangyu_front', ['工作量饱和度', '30%', '代码整洁'], ['文档质量']) # 金亮=NULL(后端):饱和度20%、有文档质量行、初审/复审 perf_shot('金亮', 'jinliang_backend', ['文档质量', '初审'], []) # 2) 用户管理:编辑郭尚雨 → 开发方向下拉 page.goto(f'{BASE}/#/user', wait_until='domcontentloaded'); page.wait_for_timeout(6000) urow = page.locator('tr:has-text("郭尚雨")').first if urow.count(): urow.locator('button:has-text("修改")').first.click(); page.wait_for_timeout(4000) dlg = page.locator('.el-dialog:visible') body = dlg.inner_text() if dlg.count() else page.locator('body').inner_text() has_dir = '开发方向' in body # 下拉里应显示 前端 sel_val = '' loc = page.locator('.el-dialog:visible .el-select input') for i in range(loc.count()): v = loc.nth(i).input_value() if v in ('前端', '后端'): sel_val = v page.screenshot(path='tmp/pw_chg038_user_form.png', full_page=True) print(f'[user_form] 开发方向下拉={"有" if has_dir else "无"} 选中值={sel_val!r} 截图 tmp/pw_chg038_user_form.png') else: print('[user_form] 用户列表未找到郭尚雨') b.close() print('done')