feat: 根目录文档、脚本、gitignore
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
# -*- 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'
|
||||
def run(page, prog_label, cname):
|
||||
page.goto(BASE + '/#/territory', wait_until='domcontentloaded'); page.wait_for_timeout(3000)
|
||||
page.goto(f'{BASE}/#/worktime/count', wait_until='domcontentloaded'); page.wait_for_timeout(6000)
|
||||
page.locator('.el-tabs__item:has-text("月报"):visible').first.click(); page.wait_for_timeout(4000)
|
||||
page.locator('.el-select:visible').nth(1).click(); page.wait_for_timeout(1500)
|
||||
page.locator(f'.el-select-dropdown:visible li:has-text("{prog_label}")').first.click(); page.wait_for_timeout(1000)
|
||||
page.locator('button:has-text("上月"):visible').first.click(); page.wait_for_timeout(1000)
|
||||
page.locator('button:has-text("查询"):visible').first.click()
|
||||
try:
|
||||
page.wait_for_selector(f'tr:has-text("{cname}")', timeout=20000)
|
||||
except Exception:
|
||||
return None
|
||||
page.wait_for_timeout(1500)
|
||||
page.locator(f'tr:has-text("{cname}")').first.locator('button:has-text("绩效")').first.click()
|
||||
page.wait_for_timeout(12000)
|
||||
body = page.locator('body').inner_text()
|
||||
page.screenshot(path=f'tmp/pw_chg053_{prog_label}.png', full_page=True)
|
||||
# 关掉弹窗,避免阻挡下一轮
|
||||
page.keyboard.press('Escape')
|
||||
page.wait_for_timeout(1500)
|
||||
try:
|
||||
page.locator('.el-dialog__wrapper:visible').first.wait_for(state='hidden', timeout=4000)
|
||||
except Exception:
|
||||
page.reload(wait_until='domcontentloaded'); page.wait_for_timeout(4000)
|
||||
return body
|
||||
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)
|
||||
r139 = run(page, '139', '孙世超')
|
||||
print('[139]', '无行' if r139 is None else ('含车服口径(556.83/525h): ' + str(all(k in r139 for k in ['556.83', '525h']))))
|
||||
r119 = run(page, '119', '孙世超')
|
||||
print('[119]', '无行(预期)' if r119 is None else ('达标630h: ' + str('630h' in r119)))
|
||||
b.close()
|
||||
print('done')
|
||||
Reference in New Issue
Block a user