txw/tmp-zoom3.mjs
2026-06-05 12:54:11 +08:00

33 lines
1.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { chromium } from 'playwright';
const BASE = 'http://localhost:9027';
(async () => {
const browser = await chromium.launch();
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
const page = await ctx.newPage();
await page.goto(`${BASE}/view/mhzc/home`, { waitUntil: 'networkidle', timeout: 30000 });
await page.waitForSelector('.capability-section', { timeout: 20000 });
// 滚动到 capability 区域
await page.evaluate(() => {
const el = document.getElementById('section-capability');
if (el) el.scrollIntoView({ behavior: 'instant', block: 'start' });
});
await page.waitForTimeout(800);
// 点击 "碳核算平台"
await page.locator('.capability-card').nth(0).click();
await page.waitForTimeout(5000);
console.log('url:', page.url());
// 不调用 evaluate直接截图
await page.screenshot({ path: 'tmp-zoom3-no-eval.png', fullPage: false });
await browser.close();
})().catch((e) => {
console.error('TEST ERROR', e);
process.exit(1);
});