37 lines
1.8 KiB
Python
37 lines
1.8 KiB
Python
# -*- 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}/#/user', wait_until='domcontentloaded'); page.wait_for_timeout(6000)
|
|
page.locator('#userSearch').fill('guoshangyu')
|
|
page.locator('button:has-text("查询")').first.click(); page.wait_for_timeout(4000)
|
|
urow = page.locator('tr:has-text("郭尚雨")').first
|
|
if not urow.count():
|
|
urow = page.locator('tr:has-text("guoshangyu")').first
|
|
if urow.count():
|
|
urow.locator('button:has-text("修改")').first.click(); page.wait_for_timeout(5000)
|
|
dlg = page.locator('.el-dialog:visible')
|
|
body = dlg.inner_text() if dlg.count() else ''
|
|
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}')
|
|
else:
|
|
page.screenshot(path='tmp/pw_chg038_user_list.png', full_page=True)
|
|
print('[user_form] 仍未找到郭尚雨,截图 tmp/pw_chg038_user_list.png')
|
|
b.close()
|
|
print('done')
|