-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdebug-layout.js
More file actions
45 lines (37 loc) · 1.48 KB
/
debug-layout.js
File metadata and controls
45 lines (37 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage({ viewport: { width: 1400, height: 900 } });
await page.goto('http://127.0.0.1:8000/');
await page.waitForTimeout(500);
// Take screenshot
await page.screenshot({ path: '/tmp/homepage-new-layout.png', fullPage: true });
// Check the layout
const layout = await page.evaluate(() => {
const featuresSection = document.querySelector('.features-section');
const adCol = document.querySelector('.homepage-ad-col');
const adSidebar = document.querySelector('.ad-sidebar');
const mainCol = document.querySelector('.homepage-main-col');
const getInfo = (el, name) => {
if (!el) return { name, found: false };
const rect = el.getBoundingClientRect();
return {
name,
top: rect.top,
left: rect.left,
width: rect.width,
height: rect.height
};
};
return {
features: getInfo(featuresSection, 'features-section'),
mainCol: getInfo(mainCol, 'homepage-main-col'),
adCol: getInfo(adCol, 'homepage-ad-col'),
adSidebar: getInfo(adSidebar, 'ad-sidebar'),
adStartsAtFeatures: featuresSection && adCol ?
Math.abs(featuresSection.getBoundingClientRect().top - adCol.getBoundingClientRect().top) < 20 : 'unknown'
};
});
console.log('New homepage layout:', JSON.stringify(layout, null, 2));
await browser.close();
})();