output debug dom object from claude webinterface
This commit is contained in:
parent
252ec11063
commit
ef8e29fbe3
|
|
@ -567,7 +567,20 @@ class ClaudeChatInterface:
|
|||
except:
|
||||
pass
|
||||
|
||||
# Methode B: Prose-Container die NICHT in user-message sind
|
||||
# Methode B: data-testid="assistant-message" (neue Claude.ai Version)
|
||||
if not claude_elements:
|
||||
try:
|
||||
found = self.driver.find_elements(
|
||||
By.CSS_SELECTOR,
|
||||
"[data-testid='assistant-message']"
|
||||
)
|
||||
if found:
|
||||
claude_elements = found
|
||||
logger.debug(f"Claude-Nachrichten via assistant-message: {len(found)}")
|
||||
except:
|
||||
pass
|
||||
|
||||
# Methode C: Prose-Container die NICHT in user-message sind
|
||||
if not claude_elements:
|
||||
try:
|
||||
# Alle prose Elemente die nicht innerhalb von user-message sind
|
||||
|
|
@ -596,6 +609,85 @@ class ClaudeChatInterface:
|
|||
except Exception as e:
|
||||
logger.debug(f"Prose-Suche fehlgeschlagen: {e}")
|
||||
|
||||
# Methode D: Alle Nachrichten-Divs durchsuchen und nach Rolle filtern
|
||||
if not claude_elements:
|
||||
try:
|
||||
# Suche nach allen Nachrichten und filtere nach data-role oder aria-label
|
||||
found = self.driver.execute_script("""
|
||||
const msgs = [];
|
||||
// Suche nach verschiedenen Indikatoren für Claude-Nachrichten
|
||||
|
||||
// 1. data-role="assistant"
|
||||
document.querySelectorAll('[data-role="assistant"]').forEach(e => msgs.push(e));
|
||||
|
||||
// 2. aria-label enthält "assistant" oder "Claude"
|
||||
if (msgs.length === 0) {
|
||||
document.querySelectorAll('[aria-label*="assistant"], [aria-label*="Claude"]').forEach(e => msgs.push(e));
|
||||
}
|
||||
|
||||
// 3. Klasse enthält "assistant"
|
||||
if (msgs.length === 0) {
|
||||
document.querySelectorAll('[class*="assistant"]').forEach(e => {
|
||||
// Filtere Buttons und andere UI-Elemente
|
||||
if (e.tagName !== 'BUTTON' && !e.querySelector('button')) {
|
||||
msgs.push(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return msgs;
|
||||
""") or []
|
||||
if found:
|
||||
claude_elements = found
|
||||
logger.debug(f"Claude-Nachrichten via Fallback-Suche: {len(found)}")
|
||||
except Exception as e:
|
||||
logger.debug(f"Fallback-Suche fehlgeschlagen: {e}")
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# DEBUG: Falls keine Claude-Nachrichten gefunden, DOM analysieren
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
if not claude_elements and user_elements:
|
||||
try:
|
||||
# Hole DOM-Info für Debugging
|
||||
dom_info = self.driver.execute_script("""
|
||||
const info = {
|
||||
'data-testids': [],
|
||||
'classes_with_message': [],
|
||||
'classes_with_assistant': []
|
||||
};
|
||||
|
||||
// Sammle alle data-testid Werte
|
||||
document.querySelectorAll('[data-testid]').forEach(e => {
|
||||
const testid = e.getAttribute('data-testid');
|
||||
if (!info['data-testids'].includes(testid)) {
|
||||
info['data-testids'].push(testid);
|
||||
}
|
||||
});
|
||||
|
||||
// Sammle Klassen die 'message' enthalten
|
||||
document.querySelectorAll('[class*="message"]').forEach(e => {
|
||||
const cls = e.className;
|
||||
if (typeof cls === 'string' && !info['classes_with_message'].includes(cls.substring(0, 100))) {
|
||||
info['classes_with_message'].push(cls.substring(0, 100));
|
||||
}
|
||||
});
|
||||
|
||||
// Sammle Klassen die 'assistant' enthalten
|
||||
document.querySelectorAll('[class*="assistant"]').forEach(e => {
|
||||
const cls = e.className;
|
||||
if (typeof cls === 'string' && !info['classes_with_assistant'].includes(cls.substring(0, 100))) {
|
||||
info['classes_with_assistant'].push(cls.substring(0, 100));
|
||||
}
|
||||
});
|
||||
|
||||
return info;
|
||||
""")
|
||||
logger.warning(f"KEINE Claude-Nachrichten gefunden! DOM-Info: data-testids={dom_info.get('data-testids', [])[:10]}")
|
||||
logger.debug(f"Klassen mit 'message': {dom_info.get('classes_with_message', [])[:5]}")
|
||||
logger.debug(f"Klassen mit 'assistant': {dom_info.get('classes_with_assistant', [])[:5]}")
|
||||
except Exception as e:
|
||||
logger.debug(f"DOM-Analyse fehlgeschlagen: {e}")
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
# Nachrichten verarbeiten
|
||||
# ═══════════════════════════════════════════════════════════════
|
||||
|
|
|
|||
Loading…
Reference in New Issue