13 lines
1.2 KiB
JavaScript
13 lines
1.2 KiB
JavaScript
const {chromium}=require('C:/Users/Elijah/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/node_modules/playwright');
|
|
const path=require('path'),{pathToFileURL}=require('url');
|
|
(async()=>{
|
|
const browser=await chromium.launch({executablePath:'C:/Program Files/Google/Chrome/Application/chrome.exe',headless:true,args:['--disable-gpu','--disable-extensions','--no-first-run']});
|
|
try{
|
|
const page=await browser.newPage({viewport:{width:1680,height:1000}});
|
|
await page.goto(pathToFileURL(path.join(__dirname,'index.html')).href,{waitUntil:'load'});
|
|
await page.evaluate(async()=>{await document.fonts.ready;await Promise.all([...document.images].map(i=>i.decode()));});
|
|
const counts=await page.evaluate(()=>({cards:document.querySelectorAll('article').length,imagesLoaded:[...document.images].every(i=>i.naturalWidth>0),horizontalOverflow:document.documentElement.scrollWidth>innerWidth}));
|
|
if(counts.cards!==5||!counts.imagesLoaded||counts.horizontalOverflow)throw new Error(JSON.stringify(counts));
|
|
await page.screenshot({path:path.join(__dirname,'gallery-preview.png'),fullPage:true});console.log(JSON.stringify(counts));
|
|
}finally{await browser.close();}
|
|
})().catch(e=>{console.error(e);process.exitCode=1});
|