60 lines
2.3 KiB
Python
60 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Paperclip post-fix validation via Playwright.
|
|
- Visits paperclip.weval-consulting.com/WEV/agents/ceo/runs/1c46d1f5-...
|
|
- Captures screenshot (proof retry is now possible)
|
|
- Does NOT click Retry (requires user auth/authorization)
|
|
- Writes result to /opt/weval-l99/pw-paperclip-postfix-<ts>.json
|
|
"""
|
|
import json, sys, os, datetime
|
|
|
|
OUT_DIR = "/opt/weval-l99/pw-paperclip-postfix"
|
|
os.makedirs(OUT_DIR, exist_ok=True)
|
|
TS = datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
|
|
RESULT = {"ts": TS, "status": "unknown"}
|
|
|
|
try:
|
|
from playwright.sync_api import sync_playwright
|
|
except ImportError:
|
|
RESULT['status'] = 'playwright_not_installed'
|
|
print(json.dumps(RESULT))
|
|
sys.exit(0)
|
|
|
|
URL_BASE = "https://paperclip.weval-consulting.com"
|
|
RUN_PATH = "/WEV/agents/ceo/runs/1c46d1f5-c9fa-4cb3-8d10-b24a2d4dc700"
|
|
|
|
with sync_playwright() as p:
|
|
try:
|
|
browser = p.chromium.launch(headless=True, args=['--no-sandbox'])
|
|
ctx = browser.new_context(ignore_https_errors=True, viewport={'width':1440,'height':900})
|
|
page = ctx.new_page()
|
|
try:
|
|
r = page.goto(URL_BASE + RUN_PATH, timeout=20000, wait_until='domcontentloaded')
|
|
RESULT['http_status'] = r.status if r else None
|
|
RESULT['final_url'] = page.url
|
|
RESULT['title'] = page.title()
|
|
page.wait_for_timeout(2000)
|
|
shot = f"{OUT_DIR}/paperclip-run-1c46d1f5-{TS}.png"
|
|
page.screenshot(path=shot, full_page=True)
|
|
RESULT['screenshot'] = shot
|
|
# Detect elements
|
|
body_text = page.inner_text('body')[:3000] if page.query_selector('body') else ''
|
|
RESULT['has_retry'] = 'Retry' in body_text
|
|
RESULT['has_eacces'] = 'EACCES' in body_text
|
|
RESULT['has_failed'] = 'failed' in body_text.lower()
|
|
RESULT['has_login'] = ('login' in body_text.lower() or 'sign' in body_text.lower())
|
|
RESULT['status'] = 'captured'
|
|
except Exception as e:
|
|
RESULT['page_error'] = str(e)[:300]
|
|
RESULT['status'] = 'page_error'
|
|
finally:
|
|
try: browser.close()
|
|
except: pass
|
|
except Exception as e:
|
|
RESULT['status'] = 'browser_error'
|
|
RESULT['error'] = str(e)[:300]
|
|
|
|
out_json = f"{OUT_DIR}/result-{TS}.json"
|
|
json.dump(RESULT, open(out_json,'w'), indent=2)
|
|
print(json.dumps(RESULT, indent=2))
|