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
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Wait for hover card container
|
# The hover card is two-stage: basic info first, then expands to show email.
|
||||||
self._page.wait_for_selector(".lpc_ip_root_class", timeout=5000)
|
# 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:
|
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)
|
self._page.mouse.move(0, 0)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
email_el = self._page.query_selector(".lpc_ip_root_class a[href*='mailto:']")
|
||||||
email = None
|
email = None
|
||||||
for selector in [
|
if email_el:
|
||||||
".lpc_ip_root_class a[href*='mailto:']",
|
href = email_el.get_attribute("href") or ""
|
||||||
".lpc_ip_root_class [class*='email']",
|
email = href.replace("mailto:", "").strip() or email_el.inner_text().strip() or None
|
||||||
".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
|
|
||||||
self._page.mouse.move(0, 0)
|
self._page.mouse.move(0, 0)
|
||||||
time.sleep(0.5)
|
time.sleep(0.3)
|
||||||
return email
|
return email
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f" Fehler beim Lesen der Hover-Card: {e}")
|
print(f" Fehler beim Lesen der Hover-Card: {e}")
|
||||||
self._page.mouse.move(0, 0)
|
self._page.mouse.move(0, 0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user