122 行
5.3 KiB
PowerShell
122 行
5.3 KiB
PowerShell
# ==============================================================================
|
|
# BTP-17 访客雷达日志明细与 GeoIP 国家代码过滤端到端自动化测试 (P0)
|
|
# ==============================================================================
|
|
$session = "btp17"
|
|
$evidenceDir = "docs/test-evidence/round-5"
|
|
$screenshotPath = "$evidenceDir/btp-17-radar-log.png"
|
|
$filterScreenshotPath = "$evidenceDir/btp-17-radar-filter-germany.png"
|
|
$initScript = "docs/test-evidence/round-5/browser-init.js"
|
|
|
|
Write-Host "=================================================================="
|
|
Write-Host " OmniCard AI (CRMmp) - BTP-17 访客雷达日志明细与 GeoIP 国家过滤测试"
|
|
Write-Host " Session: $session"
|
|
Write-Host " Evidence: $screenshotPath"
|
|
Write-Host "=================================================================="
|
|
|
|
# 步骤 1: 登录系统
|
|
Write-Host "`n>>> [Step 1/5] 打开登录页面 http://localhost:5173/login 并点击登录..."
|
|
agent-browser --session $session open "http://localhost:5173/login" --init-script $initScript
|
|
agent-browser --session $session wait 1500
|
|
agent-browser --session $session click "button.arco-btn-primary"
|
|
agent-browser --session $session wait 2000
|
|
|
|
$currentUrl = agent-browser --session $session eval "window.location.href"
|
|
Write-Host "登录完成,当前 URL: $currentUrl"
|
|
|
|
# 步骤 2: 导航至访客雷达日志页面
|
|
Write-Host "`n>>> [Step 2/5] 导航至访客雷达日志页面 http://localhost:5173/crm/radar-log..."
|
|
agent-browser --session $session open "http://localhost:5173/crm/radar-log" --init-script $initScript
|
|
agent-browser --session $session wait 2500
|
|
|
|
$pageUrl = agent-browser --session $session eval "window.location.href"
|
|
Write-Host "访客雷达日志页面已加载: $pageUrl"
|
|
|
|
# 步骤 3: 检查筛选面板结构
|
|
Write-Host "`n>>> [Step 3/5] 检查筛选面板结构 (Card ID, Touch Type, Country, Search, Reset)..."
|
|
$jsCheckFilters = @'
|
|
({
|
|
hasCardId: Boolean(document.querySelector('input[placeholder*="card" i], input[id*="cardId"]')),
|
|
hasTouchType: Boolean(document.querySelector('.arco-select')),
|
|
hasCountry: Boolean(document.querySelector('input[placeholder*="country" i], input[id*="country"]')),
|
|
hasSearch: Boolean(document.querySelector('form.arco-form button[type="submit"]')),
|
|
hasReset: Boolean(Array.from(document.querySelectorAll('form.arco-form button')).some(function(b) {
|
|
return b.innerText.indexOf('Reset') !== -1 || b.innerText.indexOf('重置') !== -1;
|
|
}))
|
|
})
|
|
'@
|
|
|
|
$filterCheck = agent-browser --session $session eval $jsCheckFilters
|
|
Write-Host "筛选面板组件检查结果: $filterCheck"
|
|
|
|
# 步骤 4: 检查表格列头与全量多国访客轨迹记录
|
|
Write-Host "`n>>> [Step 4/5] 检查表格数据与列头..."
|
|
$jsHeaders = @'
|
|
Array.from(document.querySelectorAll('.arco-table-th')).map(function(th) {
|
|
return th.innerText.trim();
|
|
})
|
|
'@
|
|
$headers = agent-browser --session $session eval $jsHeaders
|
|
Write-Host "表格列头: $headers"
|
|
|
|
$jsGetRows = @'
|
|
Array.from(document.querySelectorAll('tbody tr')).map(function(tr) {
|
|
return Array.from(tr.querySelectorAll('td')).map(function(td) {
|
|
return td.innerText.trim();
|
|
}).join(' | ');
|
|
})
|
|
'@
|
|
$allRows = agent-browser --session $session eval $jsGetRows
|
|
Write-Host "全量访客轨迹记录:"
|
|
Write-Host $allRows
|
|
|
|
# 步骤 5: 截取全量证据截图并验证 GeoIP 国家代码过滤
|
|
Write-Host "`n>>> [Step 5/5] 截取主验收截图并验证 GeoIP 国家代码过滤..."
|
|
agent-browser --session $session screenshot $screenshotPath
|
|
Write-Host "已截取主验收截图: $screenshotPath"
|
|
|
|
# 过滤 Germany
|
|
Write-Host "`n执行国家代码过滤 (Germany)..."
|
|
$jsFilterGermany = @'
|
|
(function() {
|
|
var input = document.querySelector('input[placeholder*="country" i]');
|
|
var setter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value').set;
|
|
setter.call(input, 'Germany');
|
|
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
input.dispatchEvent(new Event('change', { bubbles: true }));
|
|
var submitBtn = document.querySelector('form.arco-form button[type="submit"]');
|
|
if (submitBtn) submitBtn.click();
|
|
})()
|
|
'@
|
|
agent-browser --session $session eval $jsFilterGermany
|
|
agent-browser --session $session wait 1500
|
|
|
|
$germanyRows = agent-browser --session $session eval $jsGetRows
|
|
Write-Host "过滤 Germany 结果: $germanyRows"
|
|
agent-browser --session $session screenshot $filterScreenshotPath
|
|
Write-Host "已截取过滤 Germany 截图: $filterScreenshotPath"
|
|
|
|
# 点击重置
|
|
Write-Host "`n执行表单重置..."
|
|
$jsReset = @'
|
|
(function() {
|
|
var btns = Array.from(document.querySelectorAll('form.arco-form button'));
|
|
var resetBtn = btns.find(function(b) {
|
|
return b.innerText.indexOf('Reset') !== -1 || b.innerText.indexOf('重置') !== -1;
|
|
});
|
|
if (resetBtn) resetBtn.click();
|
|
})()
|
|
'@
|
|
agent-browser --session $session eval $jsReset
|
|
agent-browser --session $session wait 1500
|
|
|
|
$restoredRows = agent-browser --session $session eval $jsGetRows
|
|
Write-Host "重置后恢复记录数: $restoredRows"
|
|
|
|
# 重新保存最终截图(全量状态)
|
|
agent-browser --session $session screenshot $screenshotPath
|
|
Write-Host "最终确认主证据截图: $screenshotPath"
|
|
|
|
Write-Host "`n=================================================================="
|
|
Write-Host " BTP-17 测试全部执行通过![PASS]"
|
|
Write-Host "=================================================================="
|