# -*- coding: utf-8 -*- 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) 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_timeout(6000) mi = page.locator('input[placeholder="选择月"]:visible') print('month input value:', mi.first.input_value() if mi.count() else 'N/A') prj = page.locator('.el-select:visible input').first print('product select value:', prj.input_value() if prj.count() else 'N/A') rows = page.locator('table tr:visible') print('visible rows:', rows.count()) for i in range(min(rows.count(), 15)): print(i, rows.nth(i).inner_text().replace('\n', ' | ')[:120]) page.screenshot(path='tmp/pw_dbg_month3.png', full_page=True) b.close() print('done')