File size: 1,027 Bytes
8c43728
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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();
})();