2 changed files with 53 additions and 0 deletions

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
#!/usr/bin/env python3
"""验证顶栏新增「更多素材」菜单:出现 + 点击新窗口打开目标 URL"""
import sys, asyncio
BASE = "https://127.0.0.1:3005"
TARGET = "https://doc.88531.cn/docs/mrfx/mrfx-1g99qum57n5qk"
async def main():
from playwright.async_api import async_playwright
async with async_playwright() as p:
browser = await p.chromium.launch(args=["--ignore-certificate-errors"])
ctx = await browser.new_context(ignore_https_errors=True,
viewport={"width": 1600, "height": 900})
page = await ctx.new_page()
errs = []
page.on("pageerror", lambda e: errs.append(str(e)))
await page.goto(BASE + "/", wait_until="domcontentloaded", timeout=120000)
await page.wait_for_timeout(6000)
link = page.locator("a", has_text="更多素材")
n = await link.count()
print("菜单项存在:", n, "PASS" if n == 1 else "FAIL")
if n:
info = await link.first.evaluate("el => ({href: el.href, target: el.target, text: el.innerText.trim()})")
print("链接:", info)
print("URL正确:", "PASS" if info["href"] == TARGET else "FAIL " + info["href"])
print("新窗口:", "PASS" if info["target"] == "_blank" else "FAIL")
# 点击并捕获新标签页
async with ctx.expect_page() as newp:
await link.first.click()
np = await newp.value
await np.wait_for_load_state("domcontentloaded", timeout=60000)
print("新标签URL:", np.url, "PASS" if np.url.rstrip("/") == TARGET.rstrip("/") else "FAIL")
title = await np.title()
print("目标页title:", title)
await np.close()
print("JS errors:", errs[:5])
await page.screenshot(path="/vol1/1000/HD1/APP/hermes/awork/unicut_nav_check.png")
await browser.close()
asyncio.run(main())
+9
View File
@@ -116,6 +116,15 @@ const Header = (props: IProps) => {
>
MCP 使用说明
</NavLink>
{/* 更多素材:外部资源站(MinDoc 文档),新窗口打开 */}
<a
href="https://doc.88531.cn/docs/mrfx/mrfx-1g99qum57n5qk"
className={styles.text}
target="_blank"
rel="noreferrer"
>
更多素材
</a>
{/* <a
href={languageType === 'en-US' ? '/docs/en' : '/docs'}
target="_blank"