#!/usr/bin/env python3
"""Capture de vérification après corrections"""
import asyncio
from playwright.async_api import async_playwright

async def main():
    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=True)
        page = await browser.new_page(viewport={"width": 1920, "height": 1080})

        print("Navigation vers la page SneakSafe corrigee...")
        await page.goto("https://www.ysenra.fr/products/sneaksafe-sac-lavage-chaussures", wait_until="networkidle", timeout=30000)
        await page.wait_for_timeout(3000)

        # Capture complète
        print("Capture page complete...")
        await page.screenshot(path="C:\\ASSISTANT_IA\\artifacts\\SNEAKSAFE_APRES_CORRECTION_29102026.png", full_page=True)

        # Capture du hero
        print("Capture hero...")
        await page.screenshot(path="C:\\ASSISTANT_IA\\artifacts\\SNEAKSAFE_HERO_APRES_29102026.png", clip={"x": 0, "y": 0, "width": 1920, "height": 1080})

        # Vérifier la section Trio
        print("Recherche section Trio...")
        trio = await page.query_selector("text=Trio Stratégique")
        if trio:
            await trio.scroll_into_view_if_needed()
            await page.wait_for_timeout(1000)
            await trio.screenshot(path="C:\\ASSISTANT_IA\\artifacts\\SNEAKSAFE_TRIO_APRES_29102026.png")
            print("[OK] Section Trio capturee")

        # Vérifier les images chargées
        images_ok = 0
        images_ko = 0
        images = await page.query_selector_all("img")
        for img in images[:25]:
            nw = await img.evaluate("el => el.naturalWidth")
            if nw > 0:
                images_ok += 1
            else:
                images_ko += 1

        print(f"\nVerification images : {images_ok} OK / {images_ko} KO")
        print("\nCaptures sauvegardees dans C:\\ASSISTANT_IA\\artifacts\\")
        await browser.close()

if __name__ == "__main__":
    asyncio.run(main())
