39 lines
1.6 KiB
Python
39 lines
1.6 KiB
Python
import time
|
|
from pathlib import Path
|
|
from playwright.sync_api import sync_playwright
|
|
TS = time.strftime("%Y%m%d-%H%M%S")
|
|
OUT = Path(f"/var/www/html/test-report/wtp-synced-{TS}")
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
try:
|
|
with sync_playwright() as p:
|
|
browser = p.chromium.launch(headless=True, args=["--no-sandbox"])
|
|
ctx = browser.new_context(
|
|
viewport={"width":1700,"height":1200},
|
|
ignore_https_errors=True,
|
|
record_video_dir=str(OUT),
|
|
record_video_size={"width":1700,"height":1200}
|
|
)
|
|
page = ctx.new_page()
|
|
page.goto(f"https://weval-consulting.com/weval-technology-platform.html?sync={TS}", wait_until="networkidle", timeout=25000)
|
|
time.sleep(8)
|
|
page.screenshot(path=str(OUT/"wtp-synced.png"), full_page=True)
|
|
# Extract what gauges show
|
|
gauges = page.evaluate("""() => {
|
|
const out = {};
|
|
['vm-gauge-agents','vm-gauge-sovereign','vm-gauge-cov','vm-gauge-hcp'].forEach(id => {
|
|
const el = document.getElementById(id);
|
|
if (el) out[id] = el.innerText || el.textContent;
|
|
});
|
|
// Also the SVG text gauges
|
|
document.querySelectorAll('[id*=gauge] text, [class*=gauge] text').forEach((t,i) => {
|
|
out['svg_' + i] = t.textContent;
|
|
});
|
|
return out;
|
|
}""")
|
|
print("Gauge values:")
|
|
for k, v in gauges.items():
|
|
print(f" {k}: {v[:80] if isinstance(v, str) else v}")
|
|
ctx.close(); browser.close()
|
|
except Exception as e:
|
|
print(f"err: {e}")
|