MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / __init__

Method __init__

py/selenium/webdriver/support/wait.py:34–73  ·  view source on GitHub ↗

Constructor, takes a WebDriver instance and timeout in seconds. Args: driver: Instance of WebDriver (Ie, Firefox, Chrome or Remote) or a WebElement. timeout: Number of seconds before timing out. poll_frequency: Sleep interval between calls

(
        self,
        driver: D,
        timeout: float,
        poll_frequency: float = POLL_FREQUENCY,
        ignored_exceptions: Iterable[type[Exception]] | None = None,
    )

Source from the content-addressed store, hash-verified

32
33class WebDriverWait(Generic[D]):
34 def __init__(
35 self,
36 driver: D,
37 timeout: float,
38 poll_frequency: float = POLL_FREQUENCY,
39 ignored_exceptions: Iterable[type[Exception]] | None = None,
40 ):
41 """Constructor, takes a WebDriver instance and timeout in seconds.
42
43 Args:
44 driver: Instance of WebDriver (Ie, Firefox, Chrome or Remote) or
45 a WebElement.
46 timeout: Number of seconds before timing out.
47 poll_frequency: Sleep interval between calls. By default, it is
48 0.5 second.
49 ignored_exceptions: Iterable structure of exception classes ignored
50 during calls. By default, it contains NoSuchElementException only.
51
52 Example:
53 >>> from selenium.webdriver.common.by import By
54 >>> from selenium.webdriver.support.wait import WebDriverWait
55 >>> from selenium.common.exceptions import ElementNotVisibleException
56 >>>
57 >>> # Wait until the element is no longer visible
58 >>> is_disappeared = WebDriverWait(driver, 30, 1, (ElementNotVisibleException))
59 ... .until_not(lambda x: x.find_element(By.ID, "someId").is_displayed())
60 """
61 self._driver = driver
62 self._timeout = float(timeout)
63 self._poll = poll_frequency
64 # avoid the divide by zero
65 if self._poll == 0:
66 self._poll = POLL_FREQUENCY
67 exceptions: list = list(IGNORED_EXCEPTIONS)
68 if ignored_exceptions:
69 try:
70 exceptions.extend(iter(ignored_exceptions))
71 except TypeError: # ignored_exceptions is not iterable
72 exceptions.append(ignored_exceptions)
73 self._ignored_exceptions = tuple(exceptions)
74
75 def __repr__(self) -> str:
76 return f'<{type(self).__module__}.{type(self).__name__} (session="{self._driver.session_id}")>'

Callers

nothing calls this directly

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected