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 <noreply@anthropic.com>
main
I Luk Kim 4 months ago
parent 5fa28b3948
commit 0835522d06

@ -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:

Loading…
Cancel
Save