| 20 | |
| 21 | |
| 22 | class FedCM: |
| 23 | def __init__(self, driver) -> None: |
| 24 | self._driver = driver |
| 25 | |
| 26 | @property |
| 27 | def title(self) -> str: |
| 28 | """Gets the title of the dialog.""" |
| 29 | return self._driver.execute(Command.GET_FEDCM_TITLE)["value"].get("title") |
| 30 | |
| 31 | @property |
| 32 | def subtitle(self) -> str | None: |
| 33 | """Gets the subtitle of the dialog.""" |
| 34 | return self._driver.execute(Command.GET_FEDCM_TITLE)["value"].get("subtitle") |
| 35 | |
| 36 | @property |
| 37 | def dialog_type(self) -> str: |
| 38 | """Gets the type of the dialog currently being shown.""" |
| 39 | return self._driver.execute(Command.GET_FEDCM_DIALOG_TYPE).get("value") |
| 40 | |
| 41 | @property |
| 42 | def account_list(self) -> list[dict]: |
| 43 | """Gets the list of accounts shown in the dialog.""" |
| 44 | return self._driver.execute(Command.GET_FEDCM_ACCOUNT_LIST).get("value") |
| 45 | |
| 46 | def select_account(self, index: int) -> None: |
| 47 | """Selects an account from the dialog by index.""" |
| 48 | self._driver.execute(Command.SELECT_FEDCM_ACCOUNT, {"accountIndex": index}) |
| 49 | |
| 50 | def accept(self) -> None: |
| 51 | """Clicks the continue button in the dialog.""" |
| 52 | self._driver.execute(Command.CLICK_FEDCM_DIALOG_BUTTON, {"dialogButton": "ConfirmIdpLoginContinue"}) |
| 53 | |
| 54 | def dismiss(self) -> None: |
| 55 | """Cancels/dismisses the FedCM dialog.""" |
| 56 | self._driver.execute(Command.CANCEL_FEDCM_DIALOG) |
| 57 | |
| 58 | def enable_delay(self) -> None: |
| 59 | """Re-enables the promise rejection delay for FedCM.""" |
| 60 | self._driver.execute(Command.SET_FEDCM_DELAY, {"enabled": True}) |
| 61 | |
| 62 | def disable_delay(self) -> None: |
| 63 | """Disables the promise rejection delay for FedCM.""" |
| 64 | self._driver.execute(Command.SET_FEDCM_DELAY, {"enabled": False}) |
| 65 | |
| 66 | def reset_cooldown(self) -> None: |
| 67 | """Resets the FedCM dialog cooldown, allowing immediate retriggers.""" |
| 68 | self._driver.execute(Command.RESET_FEDCM_COOLDOWN) |