From 2caffab1fa7d83bfe58a586a2c16522fb924aff4 Mon Sep 17 00:00:00 2001 From: Oliver Hofmann Date: Sun, 17 May 2026 14:59:46 +0200 Subject: [PATCH] fix: split profile card wait into container + email; add diagnostic output --- src/teampulse/resolver.py | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/teampulse/resolver.py b/src/teampulse/resolver.py index 6f5504e..f56c84b 100644 --- a/src/teampulse/resolver.py +++ b/src/teampulse/resolver.py @@ -61,19 +61,40 @@ class Resolver: return None try: - # Wait for profile card, then extract email from mailto link - self._page.wait_for_selector(_PROFILE_EMAIL_SELECTOR, timeout=5000) - email_el = self._page.query_selector(_PROFILE_EMAIL_SELECTOR) + # Step 1: wait for the profile card container to appear + self._page.wait_for_selector(".lpc_ip_root_class", timeout=5000) + except Exception: + print(f" Profilkarte für '{display_name}' öffnet sich nicht (Klick hat nicht gewirkt).") + self._page.keyboard.press("Escape") + return None + + try: + # Step 2: extract email — try mailto link first, then plain text fallbacks email = None - if email_el: - email = email_el.inner_text().strip() - if not email or "@" not in email: - href = email_el.get_attribute("href") or "" - email = href.replace("mailto:", "").strip() or 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: + # Diagnose: show card text content + 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. Karteninhalt: {card_text!r}") + self._page.keyboard.press("Escape") time.sleep(0.5) return email except Exception as e: - print(f" Profilkarte für '{display_name}' nicht ladbar: {e}") + print(f" Fehler beim Lesen der Profilkarte: {e}") self._page.keyboard.press("Escape") return None