Files
zentao-flow/tmp/pw_reproduce_91_104.py
T

49 lines
2.2 KiB
Python

# -*- coding: utf-8 -*-
"""复现用户视角:月报列表 91 vs 点开绩效 104"""
import io, sys
from playwright.sync_api import sync_playwright
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
BASE = 'http://localhost:8089'
with sync_playwright() as p:
b = p.chromium.launch(channel='chrome', headless=False, slow_mo=300, args=['--start-maximized'])
page = b.new_page(viewport={'width': 1500, 'height': 950})
page.goto(BASE, wait_until='domcontentloaded'); page.wait_for_timeout(2000)
page.locator('input[placeholder="用户名"]').fill('admin')
page.locator('input[placeholder="密码"]').fill('123456')
page.locator('text="登录"').first.click(); page.wait_for_timeout(6000)
print('>>> 1. 数据统计-月报,切到 2026-06')
page.goto(f'{BASE}/#/worktime/count', wait_until='domcontentloaded')
page.wait_for_timeout(6000)
page.screenshot(path='tmp/pw_month_list1.png')
# 尝试切月份到 2026-06(找日期选择器)
try:
dp = page.locator('input[placeholder*="选择月份"], input[placeholder*="选择日期"], .el-date-editor input').first
dp.click(); page.wait_for_timeout(800)
page.screenshot(path='tmp/pw_month_list2.png')
except Exception as e:
print('月份选择器没找到:', e)
page.wait_for_timeout(2000)
page.screenshot(path='tmp/pw_month_list.png')
# 找郭尚雨行
row = page.locator('tr:has-text("郭尚雨")').first
print('郭尚雨行存在:', row.count() > 0)
if row.count():
row.scroll_into_view_if_needed(); page.wait_for_timeout(600)
page.screenshot(path='tmp/pw_month_row.png')
txt = row.inner_text()
print('行内容:', txt.replace('\n', ' | ')[:300])
# 点绩效按钮
btn = row.locator('button:has-text("绩效")').first
if btn.count():
btn.click(); page.wait_for_timeout(3000)
page.screenshot(path='tmp/pw_perf_dialog.png')
dlg = page.locator('.el-dialog:visible').last
print('弹窗内容前 500 字:', dlg.inner_text()[:500].replace('\n', ' | ') if dlg.count() else '无弹窗')
print('>>> 截图完成,停留 60s')
page.wait_for_timeout(60000)
b.close()