fix: wait for full hover card expansion (two-stage) with 10s timeout
This commit is contained in:
parent
5d102719d5
commit
9225c4e778
@ -92,39 +92,31 @@ class Resolver:
|
||||
return None
|
||||
|
||||
try:
|
||||
# Wait for hover card container
|
||||
self._page.wait_for_selector(".lpc_ip_root_class", timeout=5000)
|
||||
# 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
|
||||
)
|
||||
except Exception:
|
||||
print(f" Hover-Card für '{display_name}' erscheint nicht.")
|
||||
# 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.")
|
||||
self._page.mouse.move(0, 0)
|
||||
return None
|
||||
|
||||
try:
|
||||
email_el = self._page.query_selector(".lpc_ip_root_class a[href*='mailto:']")
|
||||
email = None
|
||||
for selector in [
|
||||
".lpc_ip_root_class a[href*='mailto:']",
|
||||
".lpc_ip_root_class [class*='email']",
|
||||
".lpc_ip_root_class [data-tid*='email']",
|
||||
]:
|
||||
el = self._page.query_selector(selector)
|
||||
if el:
|
||||
text = el.inner_text().strip()
|
||||
href = el.get_attribute("href") or ""
|
||||
email = (href.replace("mailto:", "").strip()
|
||||
or (text if "@" in text else None))
|
||||
if email:
|
||||
break
|
||||
|
||||
if not email:
|
||||
card = self._page.query_selector(".lpc_ip_root_class")
|
||||
card_text = card.inner_text().strip()[:200] if card else "(leer)"
|
||||
print(f" Karte geöffnet, E-Mail nicht gefunden. Inhalt: {card_text!r}")
|
||||
|
||||
# Dismiss by moving mouse away
|
||||
if email_el:
|
||||
href = email_el.get_attribute("href") or ""
|
||||
email = href.replace("mailto:", "").strip() or email_el.inner_text().strip() or None
|
||||
self._page.mouse.move(0, 0)
|
||||
time.sleep(0.5)
|
||||
time.sleep(0.3)
|
||||
return email
|
||||
|
||||
except Exception as e:
|
||||
print(f" Fehler beim Lesen der Hover-Card: {e}")
|
||||
self._page.mouse.move(0, 0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user