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)
| 1926 | return Dialog(self) |
| 1927 | |
| 1928 | def fedcm_dialog(self, timeout=5, poll_frequency=0.5, ignored_exceptions=None): |
| 1929 | """Waits for and returns the FedCM dialog. |
| 1930 | |
| 1931 | Args: |
| 1932 | timeout: How long to wait for the dialog. |
| 1933 | poll_frequency: How frequently to poll. |
| 1934 | ignored_exceptions: Exceptions to ignore while waiting. |
| 1935 | |
| 1936 | Returns: |
| 1937 | The FedCM dialog object if found. |
| 1938 | |
| 1939 | Raises: |
| 1940 | TimeoutException: If dialog doesn't appear. |
| 1941 | WebDriverException: If FedCM not supported. |
| 1942 | """ |
| 1943 | from selenium.common.exceptions import NoAlertPresentException |
| 1944 | from selenium.webdriver.common.fedcm.dialog import Dialog |
| 1945 | from selenium.webdriver.support.wait import WebDriverWait |
| 1946 | |
| 1947 | self._require_fedcm_support() |
| 1948 | |
| 1949 | if ignored_exceptions is None: |
| 1950 | ignored_exceptions = (NoAlertPresentException,) |
| 1951 | |
| 1952 | def _check_fedcm() -> Dialog | None: |
| 1953 | try: |
| 1954 | dialog = Dialog(self) |
| 1955 | return dialog if dialog.type else None |
| 1956 | except NoAlertPresentException: |
| 1957 | return None |
| 1958 | |
| 1959 | wait = WebDriverWait( |
| 1960 | self, |
| 1961 | timeout, |
| 1962 | poll_frequency=poll_frequency, |
| 1963 | ignored_exceptions=ignored_exceptions, |
| 1964 | ) |
| 1965 | return wait.until(lambda _: _check_fedcm()) |