// Open the IFPUV "Free Text Editor" from the public NOP portal and dump its form. import { chromium } from "playwright"; const URL = "https://www.public.nm.eurocontrol.int/PUBPORTAL/gateway/spec/"; const b = await chromium.launch({ headless: true }); const ctx = await b.newContext({ viewport: { width: 1500, height: 950 } }); const page = await ctx.newPage(); try { await page.goto(URL, { waitUntil: "domcontentloaded", timeout: 60000 }); await page.waitForTimeout(8000); // Click the "Free Text Editor" link; it may open a popup. const popupP = ctx.waitForEvent("page", { timeout: 15000 }).catch(() => null); await page.getByText("Free Text Editor", { exact: false }).first().click({ timeout: 15000 }); const popup = await popupP; const target = popup || page; await target.waitForTimeout(9000); await target.bringToFront?.(); console.log("EDITOR TITLE:", await target.title()); console.log("EDITOR URL :", target.url()); const dump = await target.$$eval( "textarea, input, button, [role=button], .gwt-Button, span", (nodes) => nodes .map((n) => ({ tag: n.tagName, type: n.getAttribute("type") || "", id: n.id || "", cls: (typeof n.className === "string" ? n.className : "").slice(0, 45), text: (n.innerText || n.value || n.placeholder || "").trim().slice(0, 45), })) .filter((e) => e.tag === "TEXTAREA" || e.tag === "INPUT" || (e.text && e.text.length > 1)) .slice(0, 80), ); console.log(JSON.stringify(dump, null, 0)); await target.screenshot({ path: "editor.png", fullPage: true }); console.log("screenshot -> editor.png"); } catch (e) { console.error("ERR:", e.message); } finally { await b.close(); }