fix: hover onto card itself to keep it open during stage 2 expansion

This commit is contained in:
Oliver Hofmann 2026-05-17 17:18:32 +02:00
parent 9225c4e778
commit af9a42f7eb

View File

@ -92,23 +92,23 @@ class Resolver:
return None
try:
# The hover card is two-stage: basic info first, then expands to show email.
# Wait directly for the mailto link (covers both stages, longer timeout).
self._page.wait_for_selector(
".lpc_ip_root_class a[href*='mailto:']", timeout=10_000
)
# Stage 1: wait for card container to appear
self._page.wait_for_selector(".lpc_ip_root_class", timeout=5_000)
except Exception:
# Card may have appeared but without a mailto link — check what's there
card = self._page.query_selector(".lpc_ip_root_class")
if card:
card_text = card.inner_text().strip()[:200]
print(f" Karte für '{display_name}' offen, E-Mail nicht gefunden. Inhalt: {card_text!r}")
else:
print(f" Hover-Card für '{display_name}' erscheint nicht.")
print(f" Hover-Card für '{display_name}' erscheint nicht.")
self._page.mouse.move(0, 0)
return None
try:
# Move mouse onto the card itself to keep it open while stage 2 loads
card_el = self._page.query_selector(".lpc_ip_root_class")
if card_el:
card_el.hover()
# Stage 2: wait for the email link to appear (card expands)
self._page.wait_for_selector(
".lpc_ip_root_class a[href*='mailto:']", timeout=8_000
)
email_el = self._page.query_selector(".lpc_ip_root_class a[href*='mailto:']")
email = None
if email_el:
@ -117,7 +117,9 @@ class Resolver:
self._page.mouse.move(0, 0)
time.sleep(0.3)
return email
except Exception as e:
print(f" Fehler beim Lesen der Hover-Card: {e}")
except Exception:
card = self._page.query_selector(".lpc_ip_root_class")
card_text = card.inner_text().strip()[:200] if card else "(leer)"
print(f" Karte für '{display_name}' offen, E-Mail nicht gefunden. Inhalt: {card_text!r}")
self._page.mouse.move(0, 0)
return None