Files
AccountForger-neuerUpload/social_networks/facebook/facebook_selectors.py
Claude Project Manager 3101e41451 Problem bei X gelöst
2025-08-12 00:38:23 +02:00

173 Zeilen
6.1 KiB
Python

"""
Facebook-Selektoren für die Automatisierung.
Basierend auf dem aktuellen Facebook UI (2024/2025).
"""
from typing import List, Dict, Any
class FacebookSelectors:
"""
Zentrale Sammlung aller Facebook-Selektoren für die Automatisierung.
"""
# ===== COOKIE CONSENT =====
COOKIE_DIALOG = "div[role='dialog']"
COOKIE_DECLINE_BUTTON = "div.html-div span:has-text('Optionale Cookies ablehnen')"
COOKIE_DECLINE_BUTTON_ALT = "//span[contains(text(), 'Optionale Cookies ablehnen')]"
COOKIE_ACCEPT_BUTTON = "button:has-text('Alle Cookies erlauben')"
# ===== LANDING PAGE =====
CREATE_ACCOUNT_BUTTON = "a[data-testid='open-registration-form-button']"
CREATE_ACCOUNT_BUTTON_ALT = "a:has-text('Neues Konto erstellen')"
CREATE_ACCOUNT_BUTTON_ID = "#u_0_0_gL" # ID kann sich ändern
# ===== LOGIN FORM =====
LOGIN_EMAIL_FIELD = "input[name='email']"
LOGIN_PASSWORD_FIELD = "input[name='pass']"
LOGIN_BUTTON = "button[name='login']"
LOGIN_BUTTON_ALT = "button[data-testid='royal_login_button']"
# ===== REGISTRATION FORM =====
# Name fields
REG_FIRSTNAME_FIELD = "input[name='firstname']"
REG_LASTNAME_FIELD = "input[name='lastname']"
# Birthday selects
REG_BIRTHDAY_DAY = "select[name='birthday_day']"
REG_BIRTHDAY_MONTH = "select[name='birthday_month']"
REG_BIRTHDAY_YEAR = "select[name='birthday_year']"
# Gender radio buttons
REG_GENDER_FEMALE = "input[name='sex'][value='1']"
REG_GENDER_MALE = "input[name='sex'][value='2']"
REG_GENDER_CUSTOM = "input[name='sex'][value='-1']"
# Contact info
REG_EMAIL_OR_PHONE = "input[name='reg_email__']"
REG_EMAIL_CONFIRM = "input[name='reg_email_confirmation__']" # Erscheint wenn Email eingegeben
# Password
REG_PASSWORD = "input[name='reg_passwd__']"
REG_PASSWORD_ALT = "input#password_step_input"
# Submit button
REG_SUBMIT_BUTTON = "button[name='websubmit']"
REG_SUBMIT_BUTTON_ALT = "button:has-text('Registrieren')"
REG_SUBMIT_BUTTON_EN = "button:has-text('Sign Up')"
# ===== EMAIL VERIFICATION =====
VERIFICATION_CODE_INPUT = "input#code_in_cliff"
VERIFICATION_CODE_INPUT_ALT = "input[name='code']"
VERIFICATION_CONTINUE_BUTTON = "button:has-text('Weiter')"
VERIFICATION_CONTINUE_BUTTON_EN = "button:has-text('Continue')"
# Verification success popup
VERIFICATION_OK_BUTTON = "a.layerCancel:has-text('OK')"
VERIFICATION_OK_BUTTON_ALT = "a[role='button']:has-text('OK')"
# ===== ERROR MESSAGES =====
ERROR_MESSAGE = "div[role='alert']"
ERROR_MESSAGE_ALT = "div.uiContextualLayer"
FIELD_ERROR = "div._5v-0._53im"
# ===== SUCCESS INDICATORS =====
SUCCESS_INDICATORS = [
"div[role='navigation']", # Navigation bar
"div[role='main']", # Main feed
"div[data-pagelet='Feed']", # Feed container
"a[href='/me/']", # Profile link
"div[aria-label='Facebook']", # Facebook logo
]
# ===== DIALOGS & POPUPS =====
DIALOG_CLOSE_BUTTON = "div[aria-label='Schließen']"
DIALOG_CLOSE_BUTTON_EN = "div[aria-label='Close']"
SKIP_BUTTON = "a:has-text('Überspringen')"
SKIP_BUTTON_EN = "a:has-text('Skip')"
NOT_NOW_BUTTON = "a:has-text('Jetzt nicht')"
NOT_NOW_BUTTON_EN = "a:has-text('Not Now')"
# ===== URLS =====
BASE_URL = "https://www.facebook.com"
BASE_URL_DE = "https://www.facebook.com/?locale=de_DE"
REGISTRATION_URL = "https://www.facebook.com/r.php"
LOGIN_URL = "https://www.facebook.com/login"
CONFIRM_EMAIL_URL = "https://www.facebook.com/confirmemail.php"
# ===== BUTTON TEXTS (für Fuzzy Matching) =====
BUTTON_TEXTS = {
"create_account": ["Neues Konto erstellen", "Create new account", "Sign up"],
"register": ["Registrieren", "Sign Up", "Register"],
"login": ["Anmelden", "Log In", "Login"],
"continue": ["Weiter", "Continue", "Next"],
"skip": ["Überspringen", "Skip", "Later"],
"decline_cookies": ["Optionale Cookies ablehnen", "Decline optional cookies", "Reject"],
"accept_cookies": ["Alle Cookies erlauben", "Allow all cookies", "Accept all"],
"ok": ["OK", "Okay"],
"not_now": ["Jetzt nicht", "Not Now", "Later"],
}
# ===== MONTH NAMES (für Birthday) =====
MONTH_NAMES_DE = {
1: "Jan.", 2: "Feb.", 3: "März", 4: "Apr.",
5: "Mai", 6: "Juni", 7: "Juli", 8: "Aug.",
9: "Sept.", 10: "Okt.", 11: "Nov.", 12: "Dez."
}
MONTH_NAMES_EN = {
1: "Jan", 2: "Feb", 3: "Mar", 4: "Apr",
5: "May", 6: "Jun", 7: "Jul", 8: "Aug",
9: "Sep", 10: "Oct", 11: "Nov", 12: "Dec"
}
@classmethod
def get_button_texts(cls, button_type: str) -> List[str]:
"""
Gibt eine Liste von möglichen Button-Texten zurück.
Args:
button_type: Typ des Buttons
Returns:
Liste von möglichen Texten
"""
return cls.BUTTON_TEXTS.get(button_type, [])
@classmethod
def get_month_name(cls, month: int, language: str = "de") -> str:
"""
Gibt den Monatsnamen für die Auswahl zurück.
Args:
month: Monatszahl (1-12)
language: Sprache ("de" oder "en")
Returns:
Monatsname
"""
if language == "de":
return cls.MONTH_NAMES_DE.get(month, str(month))
else:
return cls.MONTH_NAMES_EN.get(month, str(month))
@classmethod
def get_gender_selector(cls, gender: str) -> str:
"""
Gibt den passenden Selektor für das Geschlecht zurück.
Args:
gender: "male", "female" oder "custom"
Returns:
CSS-Selektor für das Geschlecht
"""
gender_map = {
"female": cls.REG_GENDER_FEMALE,
"male": cls.REG_GENDER_MALE,
"custom": cls.REG_GENDER_CUSTOM,
"weiblich": cls.REG_GENDER_FEMALE,
"männlich": cls.REG_GENDER_MALE,
"divers": cls.REG_GENDER_CUSTOM,
}
return gender_map.get(gender.lower(), cls.REG_GENDER_CUSTOM)