Waits for and returns the FedCM dialog. Args: timeout: How long to wait for the dialog. poll_frequency: How frequently to poll. ignored_exceptions: Exceptions to ignore while waiting. Returns: The FedCM dialog object if found.
(self, timeout=5, poll_frequency=0.5, ignored_exceptions=None)
| 1658 | return Dialog(self) |
| 1659 | |
| 1660 | def fedcm_dialog(self, timeout=5, poll_frequency=0.5, ignored_exceptions=None): |
| 1661 | """Waits for and returns the FedCM dialog. |
| 1662 | |
| 1663 | Args: |
| 1664 | timeout: How long to wait for the dialog. |
| 1665 | poll_frequency: How frequently to poll. |
| 1666 | ignored_exceptions: Exceptions to ignore while waiting. |
| 1667 | |
| 1668 | Returns: |
| 1669 | The FedCM dialog object if found. |
| 1670 | |
| 1671 | Raises: |
| 1672 | TimeoutException: If dialog doesn't appear. |
| 1673 | WebDriverException: If FedCM not supported. |
| 1674 | """ |
| 1675 | from selenium.common.exceptions import NoAlertPresentException |
| 1676 | from selenium.webdriver.common.fedcm.dialog import Dialog |
| 1677 | from selenium.webdriver.support.wait import WebDriverWait |
| 1678 | |
| 1679 | self._require_fedcm_support() |
| 1680 | |
| 1681 | if ignored_exceptions is None: |
| 1682 | ignored_exceptions = (NoAlertPresentException,) |
| 1683 | |
| 1684 | def _check_fedcm() -> Dialog | None: |
| 1685 | try: |
| 1686 | dialog = Dialog(self) |
| 1687 | return dialog if dialog.type else None |
| 1688 | except NoAlertPresentException: |
| 1689 | return None |
| 1690 | |
| 1691 | wait = WebDriverWait( |
| 1692 | self, |
| 1693 | timeout, |
| 1694 | poll_frequency=poll_frequency, |
| 1695 | ignored_exceptions=ignored_exceptions, |
| 1696 | ) |
| 1697 | return wait.until(lambda _: _check_fedcm()) |