Wait until the method returns a value that is False. Calls the method provided with the driver as an argument until the return value evaluates to ``False``. Args: method: A callable object that takes a WebDriver instance as an argument.
(self, method: Callable[[D], T], message: str = "")
| 121 | raise TimeoutException(message, screen, stacktrace) |
| 122 | |
| 123 | def until_not(self, method: Callable[[D], T], message: str = "") -> T | Literal[True]: |
| 124 | """Wait until the method returns a value that is False. |
| 125 | |
| 126 | Calls the method provided with the driver as an argument until the |
| 127 | return value evaluates to ``False``. |
| 128 | |
| 129 | Args: |
| 130 | method: A callable object that takes a WebDriver instance as an |
| 131 | argument. |
| 132 | message: Optional message for TimeoutException. |
| 133 | |
| 134 | Returns: |
| 135 | The result of the last call to `method`. |
| 136 | |
| 137 | Raises: |
| 138 | TimeoutException: If 'method' does not return False within the |
| 139 | WebDriverWait object's timeout. |
| 140 | |
| 141 | Example: |
| 142 | >>> from selenium.webdriver.common.by import By |
| 143 | >>> from selenium.webdriver.support.ui import WebDriverWait |
| 144 | >>> from selenium.webdriver.support import expected_conditions as EC |
| 145 | >>> |
| 146 | >>> # Wait until an element is no longer visible on the page |
| 147 | >>> wait = WebDriverWait(driver, 10) |
| 148 | >>> is_disappeared = wait.until_not(EC.visibility_of_element_located((By.ID, "exampleId"))) |
| 149 | """ |
| 150 | end_time = time.monotonic() + self._timeout |
| 151 | while True: |
| 152 | try: |
| 153 | value = method(self._driver) |
| 154 | if not value: |
| 155 | return value |
| 156 | except self._ignored_exceptions: |
| 157 | return True |
| 158 | if time.monotonic() > end_time: |
| 159 | break |
| 160 | time.sleep(self._poll) |
| 161 | raise TimeoutException(message) |