Abstract generic pattern for explicit WebDriverWait.
(self, method, timeout, msg)
| 270 | return elem_or_selector |
| 271 | |
| 272 | def _wait_for(self, method, timeout, msg): |
| 273 | """Abstract generic pattern for explicit WebDriverWait.""" |
| 274 | try: |
| 275 | _wait = ( |
| 276 | self._wd_wait |
| 277 | if timeout is None |
| 278 | else WebDriverWait(self.driver, timeout) |
| 279 | ) |
| 280 | logger.debug( |
| 281 | "method, timeout, poll => %s %s %s", |
| 282 | method, |
| 283 | _wait._timeout, # pylint: disable=protected-access |
| 284 | _wait._poll, # pylint: disable=protected-access |
| 285 | ) |
| 286 | |
| 287 | return _wait.until(method) |
| 288 | except Exception as err: |
| 289 | if callable(msg): |
| 290 | message = msg(self.driver) |
| 291 | else: |
| 292 | message = msg |
| 293 | raise TimeoutException(str(message)) from err |
| 294 | |
| 295 | def wait_for_element(self, selector, timeout=None): |
| 296 | """wait_for_element is shortcut to `wait_for_element_by_css_selector` |
no outgoing calls