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: