fix: update DOM selectors from live Teams Web inspection
This commit is contained in:
parent
3fcd457639
commit
d67a6c2a83
@ -5,10 +5,13 @@ from playwright.sync_api import Page
|
||||
|
||||
from teampulse.models import AuditEntry, AuditWindow, ChatMessage
|
||||
|
||||
# Discovered via scripts/discover_dom.py — update if Teams web changes
|
||||
# Selectors verified against Teams Web DOM (2026-05-17)
|
||||
# _MSG_SELECTOR: individual user chat messages (not system events)
|
||||
# _SENDER_SELECTOR: author name inside each message
|
||||
# _PROFILE_EMAIL_SELECTOR: mailto link inside Live Persona Card (.lpc_ip_root_class)
|
||||
_MSG_SELECTOR = "[data-tid='chat-pane-message']"
|
||||
_SENDER_SELECTOR = "[data-tid='message-author-name']"
|
||||
_PROFILE_EMAIL_SELECTOR = "[data-tid='persona-card-email']"
|
||||
_PROFILE_EMAIL_SELECTOR = ".lpc_ip_root_class a[href*='mailto:']"
|
||||
|
||||
_START_RE = re.compile(r'^!start(?:\s+"([^"]*)")?$', re.IGNORECASE)
|
||||
_STOP_RE = re.compile(r'^!stop$', re.IGNORECASE)
|
||||
|
||||
@ -52,7 +52,12 @@ class Resolver:
|
||||
target.click()
|
||||
self._page.wait_for_selector(_PROFILE_EMAIL_SELECTOR, timeout=5000)
|
||||
email_el = self._page.query_selector(_PROFILE_EMAIL_SELECTOR)
|
||||
email = email_el.inner_text().strip() if email_el else None
|
||||
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
|
||||
self._page.keyboard.press("Escape")
|
||||
time.sleep(0.5)
|
||||
return email
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user