* apply: Recorder.step_snap(page, name) captures both a JPEG screenshot and the page HTML for every major moment; every provider now calls step_snap at each logical step so failure reports contain the exact DOM and rendered state at every stage of the flow * ZIP report: each snapshot becomes snapshots/NN_<label>.jpg + snapshots/NN_<label>.html for AI-assisted debugging * web: Wohnungsliste zeigt nur noch Flats, die die eigenen Filter treffen; Match-Chip entfernt (Liste ist jetzt implizit matchend) * UI komplett auf Deutsch: Protokoll statt Logs, Administrator statt admin, Trockenmodus statt dry-run, Automatik pausiert statt circuit open, Alarm statt Alert, Abmelden statt Logout * Wohnungen-Header: Zeile 1 Info (Alarm + Filter), Zeile 2 Schalter mit echten Radio-Paaren (An/Aus) für Automatisch bewerben und Trockenmodus; hx-confirm auf den kritischen Radios; per-form CSS für sichtbaren Check-State * Protokoll: von/bis-Datumsfilter (Berliner Zeit) + CSV-Download (/logs/export.csv) mit UTC + lokaler Zeit Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
74 lines
3.1 KiB
Python
74 lines
3.1 KiB
Python
import logging
|
|
|
|
from actions import open_page
|
|
from classes.application_result import ApplicationResult
|
|
from language import _
|
|
from providers._provider import ApplyContext, Provider
|
|
|
|
logger = logging.getLogger("flat-apply")
|
|
|
|
|
|
class Gesobau(Provider):
|
|
@property
|
|
def domain(self) -> str:
|
|
return "gesobau.de"
|
|
|
|
async def apply_for_flat(self, url: str, ctx: ApplyContext) -> ApplicationResult:
|
|
r = ctx.recorder
|
|
p = ctx.profile
|
|
if not (p.immomio_email and p.immomio_password):
|
|
r.step("immomio_creds_missing", "warn")
|
|
return ApplicationResult(False, _("missing_fields"))
|
|
|
|
async with open_page(url, recorder=r) as page:
|
|
await r.step_snap(page, "extract.immomio_link")
|
|
immomio_link = await page.get_by_role("link", name="Jetzt bewerben").get_attribute("href")
|
|
|
|
await r.step_snap(page, "auth.goto")
|
|
await page.goto("https://tenant.immomio.com/de/auth/login")
|
|
await page.wait_for_timeout(1000)
|
|
|
|
await r.step_snap(page, "auth.login")
|
|
await page.locator('input[name="email"]').fill(p.immomio_email)
|
|
await page.get_by_role("button", name="Anmelden").click()
|
|
await page.wait_for_timeout(1000)
|
|
await page.locator("#password").fill(p.immomio_password)
|
|
await page.locator("#kc-login").click()
|
|
await page.wait_for_timeout(1000)
|
|
await r.step_snap(page, "auth.done")
|
|
|
|
await r.step_snap(page, "back.to_immomio", detail=immomio_link or "")
|
|
await page.goto(immomio_link)
|
|
await page.wait_for_timeout(1000)
|
|
|
|
await r.step_snap(page, "cookies.check")
|
|
cookie_accept_btn = page.get_by_role("button", name="Alle erlauben")
|
|
if await cookie_accept_btn.is_visible():
|
|
await cookie_accept_btn.click()
|
|
await r.step_snap(page, "cookies.accepted")
|
|
|
|
await r.step_snap(page, "apply.click")
|
|
await page.get_by_role("button", name="Jetzt bewerben").click()
|
|
await page.wait_for_timeout(3000)
|
|
await r.step_snap(page, "apply.clicked")
|
|
|
|
await r.step_snap(page, "already_applied.check")
|
|
if page.url == "https://tenant.immomio.com/de/properties/applications":
|
|
return ApplicationResult(False, message=_("already_applied"))
|
|
|
|
await r.step_snap(page, "answer_questions.click")
|
|
answer_questions_btn = page.get_by_role("button", name="Fragen beantworten")
|
|
if await answer_questions_btn.is_visible():
|
|
await answer_questions_btn.click()
|
|
await page.wait_for_timeout(2000)
|
|
|
|
if await answer_questions_btn.is_visible():
|
|
await answer_questions_btn.click()
|
|
await page.wait_for_timeout(2000)
|
|
|
|
await r.step_snap(page, "success.check")
|
|
if not await answer_questions_btn.is_visible():
|
|
return ApplicationResult(True)
|
|
|
|
await r.step_snap(page, "success.not_found", status="warn")
|
|
return ApplicationResult(False, _("submit_conformation_msg_not_found"))
|