53 lines
No EOL
1.9 KiB
Python
53 lines
No EOL
1.9 KiB
Python
# pages/results_page.py
|
|
from selenium.webdriver.common.by import By
|
|
from selenium.webdriver.support import expected_conditions as EC
|
|
import time
|
|
|
|
class DevPage:
|
|
MODAL_YES_BUTTON = (By.CSS_SELECTOR, "div.modal-dialog-actions button.btn--primary")
|
|
MODAL_NO_BUTTON = (By.CSS_SELECTOR, "div.modal-dialog-actions button.btn--secondary")
|
|
|
|
def __init__(self, driver, wait):
|
|
self.driver = driver
|
|
self.wait = wait
|
|
|
|
def dev_login(self, base_url, user_name="John"):
|
|
"""
|
|
Simuliert Login über /dev Seite
|
|
|
|
Args:
|
|
base_url: Basis-URL der Anwendung
|
|
user_name: Vorname des Users (z.B. "John", "Sarah", "Mike")
|
|
"""
|
|
# Navigiere zur Dev-Seite
|
|
self.driver.get(f"{base_url}/dev")
|
|
|
|
# Warte bis Tabelle geladen ist
|
|
self.wait.until(
|
|
EC.presence_of_element_located((By.CSS_SELECTOR, "table.data-table"))
|
|
)
|
|
|
|
# Finde die User-Row anhand des Vornamens
|
|
# Die Tabelle hat Spalten: First name | Last name | E-Mail | ...
|
|
rows = self.driver.find_elements(By.CSS_SELECTOR, "table.data-table tbody tr.table-row")
|
|
|
|
for row in rows:
|
|
cells = row.find_elements(By.TAG_NAME, "td")
|
|
if cells and user_name in cells[0].text: # cells[0] ist "First name"
|
|
# Klicke auf die Row
|
|
self.wait.until(EC.element_to_be_clickable(row))
|
|
row.click()
|
|
break
|
|
else:
|
|
raise Exception(f"User '{user_name}' nicht in der Dev-User-Tabelle gefunden")
|
|
|
|
# Warte auf Modal und klicke "Yes"
|
|
yes_button = self.wait.until(
|
|
EC.element_to_be_clickable(self.MODAL_YES_BUTTON)
|
|
)
|
|
yes_button.click()
|
|
|
|
# Warte bis Modal geschlossen ist
|
|
self.wait.until(
|
|
EC.invisibility_of_element_located((By.CSS_SELECTOR, "div.modal-container"))
|
|
) |