From 0835522d06eefffedc7ff753e74cf97669f27d8e Mon Sep 17 00:00:00 2001 From: I Luk Kim Date: Mon, 13 Apr 2026 10:10:30 -0700 Subject: [PATCH] aaoinfo: fix pagination click on detached DOM element Use page.click(selector) instead of ElementHandle.click() so Playwright re-queries the element at click time after AJAX page refresh. Co-Authored-By: Claude Sonnet 4.6 --- gimme_job/adapters/aaoinfo.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/gimme_job/adapters/aaoinfo.py b/gimme_job/adapters/aaoinfo.py index 45afbcb..5b76c49 100644 --- a/gimme_job/adapters/aaoinfo.py +++ b/gimme_job/adapters/aaoinfo.py @@ -33,19 +33,22 @@ class AAOInfoAdapter(ManifestDrivenAdapter): except Exception: current_first_url = None - # Try clicking the specific page number button - next_btn = page.query_selector(f"#page-item-{next_page} a") - if not next_btn: - next_btn = page.query_selector( - "ul.pagination li.page-item:not(.active):not(.disabled):last-child a" - ) + # Determine which selector to use for the next page button + primary_sel = f"#page-item-{next_page} a" + fallback_sel = "ul.pagination li.page-item:not(.active):not(.disabled):last-child a" - if not next_btn: + if page.query_selector(primary_sel): + btn_sel = primary_sel + elif page.query_selector(fallback_sel): + btn_sel = fallback_sel + else: logger.debug(f"[aaoinfo] No next page button found — stopping at page {page_index + 1}") return False logger.debug(f"[aaoinfo] Paginating to page {next_page}") - next_btn.click() + # Use page.click() (locator-based) so Playwright re-queries the element + # at click time, avoiding "not attached to DOM" errors after AJAX refresh. + page.click(btn_sel) # Wait for page indicator to become active try: