working app

This commit is contained in:
Aron Petau 2025-12-29 22:46:10 +01:00
parent 8e69e30387
commit 3057cda8d3
12 changed files with 708 additions and 232 deletions

View file

@ -90,8 +90,47 @@ class GewobagHandler(BaseHandler):
logger.info("[GEWOBAG] Clicking button...")
await apply_btn.click()
await asyncio.sleep(2)
result["success"] = True
result["message"] = "Application submitted successfully."
# --- Post-click confirmation logic ---
logger.info("[GEWOBAG] Clicked application button, checking for confirmation...")
# Save screenshot and HTML after click
try:
await page.screenshot(path="data/gewobag_after_apply.png")
logger.info("[GEWOBAG] Saved screenshot after application click.")
except Exception as e:
logger.warning(f"[GEWOBAG] Could not save screenshot: {e}")
try:
html_after = await page.content()
with open("data/gewobag_after_apply.html", "w", encoding="utf-8") as f:
f.write(html_after)
logger.info("[GEWOBAG] Saved HTML after application click.")
except Exception as e:
logger.warning(f"[GEWOBAG] Could not save HTML after apply: {e}")
# Look for confirmation message on the page
confirmation_selectors = [
'text="Vielen Dank"',
'text="Ihre Anfrage wurde gesendet"',
'text="Bestätigung"',
'div:has-text("Vielen Dank")',
'div:has-text("Ihre Anfrage wurde gesendet")',
]
confirmed = False
for sel in confirmation_selectors:
try:
el = await page.query_selector(sel)
if el and await el.is_visible():
logger.info(f"[GEWOBAG] Found confirmation element: {sel}")
confirmed = True
break
except Exception as e:
logger.debug(f"[GEWOBAG] Error checking confirmation selector {sel}: {e}")
if confirmed:
result["success"] = True
result["message"] = "Application submitted and confirmation detected."
else:
logger.warning("[GEWOBAG] No confirmation message detected after application click.")
result["success"] = False
result["message"] = "Clicked application button, but no confirmation detected. Check screenshot and HTML."
else:
result["message"] = "No application button found."
except Exception as e: