from typing import Self from selenium.webdriver.common import by from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from page_objects.base_page import BasePage class DangerZonePage(BasePage): """ Page object for the Danger Zone page. """ # Locators DELETE_ACCOUNT_BUTTON = (By.XPATH, '/html/body/div/div/main/div/div[3]/div/div[2]/button') CONFIRM_DELETE_BUTTON = (By.XPATH, '/html/body/div[3]/div[3]/button') CANCEL_DELETE_BUTTON = (By.XPATH, '/html/body/div[3]/button') DIALOG_TITLE = (By.XPATH, '/html/body/div[3]/div[1]/h2') # Assuming dialog title DIALOG_INPUT = (By.XPATH,'/html/body/div[3]/div[2]/input') _DANGER_ZONE_TITLE = (By.XPATH,'//*[@id="root"]/div/main/div/div[3]/div/div[1]/h3') def get_page_header(self): """ Gets the header text of the page. Assumes the header is an h1 element. """ return self.get_text((By.TAG_NAME, "h1")) def click_delete_account(self): """ Clicks the 'Delete Account' button to open the confirmation dialog. """ self.click(self.DELETE_ACCOUNT_BUTTON) def verify_confirmation_dialog_exist(self): return self.get_text(self.DIALOG_TITLE) def set_dialog_input(self): self.send_keys(self.DIALOG_INPUT,'delete my account') return '' def click_cancel_in_dialog(self, timeout=5): """ Safely clicks the cancel button in the confirmation dialog. """ self.click(self.CANCEL_DELETE_BUTTON) def click_confirm_in_dialog(self): """ Clicks the 'Confirm' button within the confirmation dialog. """ self.click(self.CONFIRM_DELETE_BUTTON) def verify_danger_zone_exist(self): return self.get_text(self._DANGER_ZONE_TITLE)