SPB Git forge

spb/auto-ka

Public
61commits 1branches 0releases
14.4 MBsize
maindefault branch
12 days agolast push
Python 61.6% TypeScript 20.9% CSS 11.4% JavaScript 5.1% HTML 1.1%
2.0 KB · 38 lines javascript
Raw Blame History
1import { chromium } from "playwright";2const uid = process.argv[2] || "denisauto:5168959";3const browser = await chromium.launch();4const page = await browser.newPage({ viewport: { width: 1280, height: 900 } });5const errors = [];6page.on("pageerror", (e) => errors.push(String(e)));7page.on("console", (m) => { if (m.type() === "error") errors.push(m.text()); });8await page.goto(`http://localhost:8095/vehicule/${encodeURIComponent(uid)}`, { waitUntil: "networkidle" });9await page.waitForSelector(".vdetail h1", { timeout: 15000 });10const checks = {11  titre: await page.locator(".vd-head h1").textContent(),12  badge_marche: await page.locator(".market-badge").textContent().catch(() => "ABSENT"),13  galerie: await page.locator(".gallery .main img").count(),14  compteur_photos: await page.locator(".gal-count").textContent().catch(() => "ABSENT"),15  analyse_marche: await page.locator(".mkt-stats").count(),16  scatter: await page.locator(".scatter").count(),17  carte: await page.locator(".map-embed").count(),18  autres_offres: await page.locator(".offer").count(),19  ka_score: await page.locator(".score-ball").textContent().catch(() => "ABSENT"),20  fiche_constructeur: (await page.locator(".panel h3", { hasText: "Fiche constructeur" }).count()),21  rappels: await page.locator(".recall").count(),22};23// lightbox : clic sur la photo principale24await page.locator(".gallery .main img").click();25checks.lightbox_ouverte = await page.locator(".lightbox img").count();26checks.lb_compteur = await page.locator(".lb-count").textContent().catch(() => "ABSENT");27await page.keyboard.press("ArrowRight");28await page.waitForTimeout(300);29checks.lb_apres_fleche = await page.locator(".lb-count").textContent().catch(() => "ABSENT");30await page.keyboard.press("Escape");31await page.waitForTimeout(200);32checks.lb_fermee = (await page.locator(".lightbox").count()) === 0;33// screenshot pleine page34await page.screenshot({ path: "/tmp/autoka-vehicle.png", fullPage: true });35console.log(JSON.stringify(checks, null, 2));36console.log("JS errors:", errors.length ? errors : "aucune");37await browser.close();38