helloworld / deploy /scripts /shot_wm2.js
eduzrh's picture
Upload deploy/scripts/shot_wm2.js with huggingface_hub
8c43728 verified
Raw History Blame Contribute Delete
1.03 kB
const { chromium } = require('playwright-core');
(async () => {
const b = await chromium.launch({
executablePath: '/data/tools/chrome-headless-shell-linux64/chrome-headless-shell',
args: ['--no-sandbox','--disable-dev-shm-usage','--use-gl=swiftshader','--enable-unsafe-swiftshader'],
});
const ctx = await b.newContext({ viewport:{width:1600,height:1000}, locale:'zh-CN' });
const page = await ctx.newPage();
await page.goto('http://127.0.0.1/wm/', {waitUntil:'domcontentloaded',timeout:60000});
await page.waitForTimeout(20000);
// 关掉 workspace 弹窗
for (const s of ['button:has-text("RESET")','button[aria-label="Close"]']) {
try { const e=page.locator(s).first(); if(await e.count() && await e.isVisible()){ await e.click({timeout:3000}); await page.waitForTimeout(1500);} } catch(e){}
}
await page.keyboard.press('Escape').catch(()=>{});
await page.waitForTimeout(30000);
await page.screenshot({path:'/data/shots/wm_map.png'});
console.log('shot done');
await b.close();
})();