61 lines
3.8 KiB
Python
61 lines
3.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""MD 上传演示:新建会议 → 传 MD → 保存 → 查库 → 详情在线看"""
|
|
import io, sys, pymysql
|
|
from playwright.sync_api import sync_playwright
|
|
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
|
BASE = 'http://localhost:8088'
|
|
DB = dict(host='192.168.1.161', port=3306, user='devgps', password='dev@2021GPS', database='zentao_dev', charset='utf8mb4', autocommit=True)
|
|
def db(sql, args=()):
|
|
conn = pymysql.connect(**DB); cur = conn.cursor(); cur.execute(sql, args)
|
|
r = cur.fetchone(); conn.close(); return r
|
|
|
|
with sync_playwright() as p:
|
|
b = p.chromium.launch(channel='chrome', headless=False, slow_mo=500, 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)
|
|
|
|
page.goto(f'{BASE}/#/product-meeting/145', wait_until='domcontentloaded'); page.wait_for_timeout(5000)
|
|
page.locator('button.el-button--primary:has-text("会议纪要")').first.click(); page.wait_for_timeout(3000)
|
|
dlg = page.locator('.el-dialog:visible').last
|
|
|
|
dlg.locator('.el-select').nth(1).click(); page.wait_for_timeout(1000)
|
|
page.locator('.el-select-dropdown:visible .el-select-dropdown__item:has-text("需求会议")').first.click(); page.wait_for_timeout(1000)
|
|
dp = dlg.locator('input[placeholder="选择日期"]').first
|
|
dp.click(); page.wait_for_timeout(500); dp.fill('2026-07-29 15:00:00'); page.keyboard.press('Enter'); page.wait_for_timeout(500)
|
|
dlg.locator('.el-form-item:has-text("会议地点") input').fill('演示会议室')
|
|
dlg.locator('.el-form-item:has-text("参会人") .el-select').first.click(); page.wait_for_timeout(1200)
|
|
page.locator('.el-select-dropdown:visible .el-select-dropdown__item').first.click(); page.wait_for_timeout(600)
|
|
page.keyboard.press('Escape'); page.wait_for_timeout(500)
|
|
dlg.locator('.el-form-item:has-text("会议主题") input').fill('MD上传演示会议')
|
|
for label, content in [('讨论的内容', '演示:上传 MD 纪要'), ('讨论的结果', '通过'), ('后续行动安排', '无')]:
|
|
ed = dlg.locator(f'.el-form-item:has-text("{label}") .ql-editor, .el-form-item:has-text("{label}") [contenteditable="true"]').first
|
|
ed.click(); page.wait_for_timeout(300); page.keyboard.type(content, delay=20)
|
|
|
|
print('>>> 上传 MD ...')
|
|
dlg.locator('input[type="file"]').first.set_input_files('tmp/smoke_worklog.md')
|
|
page.wait_for_timeout(3000)
|
|
page.screenshot(path='tmp/pw_md_upload_dialog.png', full_page=False)
|
|
|
|
print('>>> 保存会议 ...')
|
|
dlg.locator('button:has-text("确 定")').first.click(); page.wait_for_timeout(5000)
|
|
r = db("SELECT id, title, url FROM zt_meeting WHERE title LIKE %s ORDER BY id DESC LIMIT 1", ('%MD上传演示%',))
|
|
print('会议落库:', r)
|
|
if r:
|
|
mid = r[0]
|
|
f = db("SELECT id, title FROM zt_file WHERE objecttype='meeting' AND objectid=%s ORDER BY id DESC LIMIT 1", (mid,))
|
|
print('附件落库:', f)
|
|
page.goto(f'{BASE}/#/product-meeting-info/{mid}', wait_until='domcontentloaded'); page.wait_for_timeout(5000)
|
|
page.locator('text=附件').first.scroll_into_view_if_needed(); page.wait_for_timeout(1200)
|
|
btn = page.locator('text="在线查看"').first
|
|
if btn.count() == 0:
|
|
btn = page.locator('text="查看"').first
|
|
btn.click(); page.wait_for_timeout(4000)
|
|
page.screenshot(path='tmp/pw_md_demo_final.png', full_page=False)
|
|
print('>>> 详情页附件+在线渲染已展示,窗口停留5分钟')
|
|
page.wait_for_timeout(300000)
|
|
b.close()
|