71 lines
2.6 KiB
TypeScript
71 lines
2.6 KiB
TypeScript
import { chromium } from 'playwright';
|
|
|
|
const GOOGLE_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
|
|
|
|
async function main() {
|
|
console.log('Checking BEST Dispensary Treez menu for pagination...');
|
|
|
|
const browser = await chromium.launch({ headless: false });
|
|
const context = await browser.newContext({ userAgent: GOOGLE_UA });
|
|
const page = await context.newPage();
|
|
|
|
try {
|
|
console.log('Loading menu page...');
|
|
await page.goto('https://best.treez.io/onlinemenu/?customerType=ADULT', {
|
|
waitUntil: 'networkidle',
|
|
timeout: 30000
|
|
});
|
|
|
|
await page.waitForTimeout(3000);
|
|
|
|
// Check initial count
|
|
const initialItems = await page.locator('.menu-item').all();
|
|
console.log(`Initial menu items found: ${initialItems.length}`);
|
|
|
|
// Check for pagination controls
|
|
const paginationButtons = await page.locator('button:has-text("Next"), button:has-text("Load More"), .pagination, [class*="page"], [class*="Pagination"]').all();
|
|
console.log(`Pagination controls found: ${paginationButtons.length}`);
|
|
|
|
// Check page height and scroll
|
|
const scrollHeight = await page.evaluate(() => document.body.scrollHeight);
|
|
console.log(`Page scroll height: ${scrollHeight}px`);
|
|
|
|
// Try scrolling to bottom
|
|
console.log('Scrolling to bottom...');
|
|
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
|
|
await page.waitForTimeout(2000);
|
|
|
|
// Check if more items loaded after scroll
|
|
const afterScrollItems = await page.locator('.menu-item').all();
|
|
console.log(`Menu items after scroll: ${afterScrollItems.length}`);
|
|
|
|
// Check for categories/filters
|
|
const categories = await page.locator('[class*="category"], [class*="filter"], nav a, .nav-link').all();
|
|
console.log(`Category/filter links found: ${categories.length}`);
|
|
|
|
if (categories.length > 0) {
|
|
console.log('\nCategory links:');
|
|
for (let i = 0; i < Math.min(categories.length, 10); i++) {
|
|
const text = await categories[i].textContent();
|
|
const href = await categories[i].getAttribute('href');
|
|
console.log(` - ${text?.trim()} (${href})`);
|
|
}
|
|
}
|
|
|
|
// Take a screenshot
|
|
await page.screenshot({ path: '/tmp/treez-menu-check.png', fullPage: true });
|
|
console.log('\nScreenshot saved to /tmp/treez-menu-check.png');
|
|
|
|
// Get page HTML to analyze structure
|
|
const html = await page.content();
|
|
console.log(`\nPage HTML length: ${html.length} characters`);
|
|
|
|
} catch (error: any) {
|
|
console.error('Error:', error.message);
|
|
} finally {
|
|
await browser.close();
|
|
}
|
|
}
|
|
|
|
main().catch(console.error);
|