# -*- coding: utf-8 -*- """9130 历史记录显示截图(AI 拆 2 任务后的真实渲染)""" 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: browser = p.chromium.launch(channel='chrome', headless=True, args=['--disable-gpu']) page = browser.new_page(viewport={'width': 1500, 'height': 950}) page.goto(BASE, wait_until='domcontentloaded'); page.wait_for_timeout(2500) if 'login' in page.url: page.locator('input[placeholder="用户名"]').fill('admin') page.locator('input[placeholder="密码"]').fill('123456') page.locator('text="登录"').first.click(); page.wait_for_timeout(6000) page.goto(f'{BASE}/#/product-story-info/9130', wait_until='domcontentloaded') page.wait_for_timeout(6000) # 滚动到历史记录区块 try: page.locator('text=历史记录').first.scroll_into_view_if_needed(); page.wait_for_timeout(1500) except Exception as e: print('历史记录区块定位失败:', e) page.screenshot(path='tmp/pw_9130_history.png', full_page=False) # 抓历史记录文本内容 body = page.inner_text('body') idx = body.find('历史记录') print(body[idx:idx+500] if idx >= 0 else '未找到历史记录区块') browser.close()