"""One-off: rebuild UPRN 100010086084's Openings page with 4 separate per-orientation window rows (N/E/S/W, 2.516 m^2 each) instead of the single combined South-facing row, to test whether it closes the ~2pt gap between Elmhurst's own worksheet (51) and this engine on gov-API inputs (53). Each window is added in its OWN fresh `E.session()` (fresh login, fresh page load of Openings) to dodge the documented "each Add wipes the previous row's editable cells" bug AND the flaky in-process re-navigation after Save & Close observed in earlier runs. Run once per window, e.g.: DISPLAY=:99 python scripts/hyde/build_100010086084_multiwindow.py East DISPLAY=:99 python scripts/hyde/build_100010086084_multiwindow.py South DISPLAY=:99 python scripts/hyde/build_100010086084_multiwindow.py West """ from __future__ import annotations import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).parent)) import elmhurst_lib as E # noqa: E402 AREA = 2.516 def main() -> None: if len(sys.argv) != 2: raise SystemExit(f"usage: {sys.argv[0]} ") orientation = sys.argv[1] with E.session() as (ctx, page): E.goto(page, "Openings", "WebFormOpenings.aspx") before = E.window_row_count(page) print("before:", before) E.add_combined_window(page, AREA, orientation) page.wait_for_timeout(800) after = E.window_row_count(page) print("after add:", after) rows = page.evaluate( """() => { const cells = document.querySelectorAll("[id*='GridViewExtendedWidows'] tr"); return [...cells].map(r => r.innerText.replace(/\\s+/g, ' ').trim()); }""" ) for r in rows: print("ROW:", r) E.save_close(page) if __name__ == "__main__": main()