CoolFace
Apppublic

ofc01/sentinel-zero

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
test_browser.py51 linesDownload Raw Back to root
1import time2from selenium import webdriver3from selenium.webdriver.edge.options import Options4 5def test_url(url):6    print(f"\n--- Testing URL: {url} ---")7    options = Options()8    options.add_argument('--headless')9    options.add_argument('--disable-gpu')10    11    # We want to capture console logs12    options.set_capability('goog:loggingPrefs', {'browser': 'ALL'})13    14    try:15        driver = webdriver.Edge(options=options)16        driver.get(url)17        time.sleep(3)  # Wait for JS to execute18        19        logs = driver.get_log('browser')20        if not logs:21            print("No console logs/errors found.")22        else:23            for log in logs:24                print(f"[{log['level']}] {log['message']}")25                26        # Also check if canvas has rendered anything by executing JS27        canvas_check = driver.execute_script('''28            const canvas = document.getElementById('bg-canvas');29            if (!canvas) return "NO_CANVAS";30            const ctx = canvas.getContext('2d');31            const data = ctx.getImageData(0, 0, canvas.width, canvas.height).data;32            let sum = 0;33            for(let i=0; i<data.length; i+=4) { sum += data[i] + data[i+1] + data[i+2]; }34            return "Canvas rendered (sum: " + sum + ")";35        ''')36        print(f"Canvas Check: {canvas_check}")37        38    except Exception as e:39        print(f"Failed to test {url}: {e}")40    finally:41        try:42            driver.quit()43        except:44            pass45 46if __name__ == '__main__':47    import os48    abs_path = os.path.abspath('frontend/index.html').replace('\\\\', '/')49    test_url(f"file:///{abs_path}")50    test_url("http://127.0.0.1:8001")51