@@ -40,32 +40,23 @@ def __init__(
4040 ):
4141 """Constructor, takes a WebDriver instance and timeout in seconds.
4242
43- Attributes:
44- -----------
45- driver
46- - Instance of WebDriver (Ie, Firefox, Chrome or Remote) or
47- a WebElement
48-
49- timeout
50- - Number of seconds before timing out
51-
52- poll_frequency
53- - Sleep interval between calls
54- - By default, it is 0.5 second.
55-
56- ignored_exceptions
57- - Iterable structure of exception classes ignored during calls.
58- - By default, it contains NoSuchElementException only.
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.
5951
6052 Example:
61- --------
62- >>> from selenium.webdriver.common.by import By
63- >>> from selenium.webdriver.support.wait import WebDriverWait
64- >>> from selenium.common.exceptions import ElementNotVisibleException
65- >>>
66- >>> # Wait until the element is no longer visible
67- >>> is_disappeared = WebDriverWait(driver, 30, 1, (ElementNotVisibleException))
68- ... .until_not(lambda x: x.find_element(By.ID, "someId").is_displayed())
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())
6960 """
7061 self ._driver = driver
7162 self ._timeout = float (timeout )
@@ -90,35 +81,27 @@ def until(self, method: Callable[[D], Union[Literal[False], T]], message: str =
9081 Calls the method provided with the driver as an argument until the
9182 return value does not evaluate to ``False``.
9283
93- Parameters:
94- -----------
95- method: callable(WebDriver)
96- - A callable object that takes a WebDriver instance as an argument.
97-
98- message: str
99- - Optional message for :exc:`TimeoutException`
84+ Args:
85+ method: A callable object that takes a WebDriver instance as an
86+ argument.
87+ message: Optional message for TimeoutException.
10088
101- Return:
102- -------
103- object: T
104- - The result of the last call to `method`
89+ Returns:
90+ The result of the last call to `method`.
10591
10692 Raises:
107- -------
108- TimeoutException
109- - If 'method' does not return a truthy value within the WebDriverWait
110- object's timeout
93+ TimeoutException: If 'method' does not return a truthy value within
94+ the WebDriverWait object's timeout.
11195
11296 Example:
113- --------
114- >>> from selenium.webdriver.common.by import By
115- >>> from selenium.webdriver.support.ui import WebDriverWait
116- >>> from selenium.webdriver.support import expected_conditions as EC
117-
118- # Wait until an element is visible on the page
119- >>> wait = WebDriverWait(driver, 10)
120- >>> element = wait.until(EC.visibility_of_element_located((By.ID, "exampleId")))
121- >>> print(element.text)
97+ >>> from selenium.webdriver.common.by import By
98+ >>> from selenium.webdriver.support.ui import WebDriverWait
99+ >>> from selenium.webdriver.support import expected_conditions as EC
100+ >>>
101+ >>> # Wait until an element is visible on the page
102+ >>> wait = WebDriverWait(driver, 10)
103+ >>> element = wait.until(EC.visibility_of_element_located((By.ID, "exampleId")))
104+ >>> print(element.text)
122105 """
123106 screen = None
124107 stacktrace = None
@@ -138,39 +121,31 @@ def until(self, method: Callable[[D], Union[Literal[False], T]], message: str =
138121 raise TimeoutException (message , screen , stacktrace )
139122
140123 def until_not (self , method : Callable [[D ], T ], message : str = "" ) -> Union [T , Literal [True ]]:
141- """Wait until the method returns a value that is not False.
124+ """Wait until the method returns a value that is False.
142125
143126 Calls the method provided with the driver as an argument until the
144- return value does not evaluate to ``False``.
145-
146- Parameters:
147- -----------
148- method: callable(WebDriver)
149- - A callable object that takes a WebDriver instance as an argument.
127+ return value evaluates to ``False``.
150128
151- message: str
152- - Optional message for :exc:`TimeoutException`
129+ Args:
130+ method: A callable object that takes a WebDriver instance as an
131+ argument.
132+ message: Optional message for TimeoutException.
153133
154- Return:
155- -------
156- object: T
157- - The result of the last call to `method`
134+ Returns:
135+ The result of the last call to `method`.
158136
159137 Raises:
160- -------
161- TimeoutException
162- - If 'method' does not return False within the WebDriverWait
163- object's timeout
138+ TimeoutException: If 'method' does not return False within the
139+ WebDriverWait object's timeout.
164140
165141 Example:
166- --------
167- >>> from selenium.webdriver.common.by import By
168- >>> from selenium.webdriver.support.ui import WebDriverWait
169- >>> from selenium.webdriver.support import expected_conditions as EC
170-
171- # Wait until an element is visible on the page
172- >>> wait = WebDriverWait(driver, 10)
173- >>> is_disappeared = wait.until_not(EC.visibility_of_element_located((By.ID, "exampleId")))
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")))
174149 """
175150 end_time = time .monotonic () + self ._timeout
176151 while True :
0 commit comments