仰望星辰工作室

miaopanel

miaopanel/ scripts/ui-shot-waf.mjs 1.1 KB · 30 行 原始文件
1// Capture the standalone WAF dashboard and its tabs.
2import { chromium } from 'playwright'
3
4const base = process.argv[2]
5const password = process.argv[3]
6const out = process.argv[4] || '.'
7
8const browser = await chromium.launch()
9const page = await browser.newPage({ viewport: { width: 1440, height: 1000 }, deviceScaleFactor: 2 })
10
11await page.goto(base + '/', { waitUntil: 'networkidle' })
12await page.fill('input[autocomplete="username"]', 'admin')
13await page.fill('input[type="password"]', password)
14await page.click('button[type="submit"]')
15await page.waitForTimeout(2200)
16
17await page.getByRole('button', { name: 'WAF 防火墙' }).click()
18await page.waitForTimeout(4000)
19await page.screenshot({ path: `${out}/ui-waf.png`, fullPage: true })
20
21await page.getByRole('button', { name: '自定义规则' }).click()
22await page.waitForTimeout(600)
23await page.screenshot({ path: `${out}/ui-waf-rules.png`, fullPage: true })
24
25await page.getByRole('button', { name: '防护设置' }).click()
26await page.waitForTimeout(600)
27await page.screenshot({ path: `${out}/ui-waf-settings.png`, fullPage: true })
28
29await browser.close()
30console.log('waf screenshots written to', out)