1515# limitations under the License.
1616
1717import time
18+ from datetime import timedelta
1819from typing import Optional , Union
1920
2021from selenium .common .exceptions import StaleElementReferenceException
@@ -29,7 +30,7 @@ class WaitingKeywords(LibraryComponent):
2930 def wait_for_condition (
3031 self ,
3132 condition : str ,
32- timeout : Union [ str , float , None ] = None ,
33+ timeout : Optional [ timedelta ] = None ,
3334 error : Optional [str ] = None ,
3435 ):
3536 """Waits until ``condition`` is true or ``timeout`` expires.
@@ -64,7 +65,7 @@ def wait_for_condition(
6465 def wait_until_location_is (
6566 self ,
6667 expected : str ,
67- timeout : Union [ str , float , None ] = None ,
68+ timeout : Optional [ timedelta ] = None ,
6869 message : Optional [str ] = None ,
6970 ):
7071 """Waits until the current URL is ``expected``.
@@ -93,7 +94,7 @@ def wait_until_location_is(
9394 def wait_until_location_is_not (
9495 self ,
9596 location : str ,
96- timeout : Union [ str , float , None ] = None ,
97+ timeout : Optional [ timedelta ] = None ,
9798 message : Optional [str ] = None ,
9899 ):
99100 """Waits until the current URL is not ``location``.
@@ -121,7 +122,7 @@ def wait_until_location_is_not(
121122 def wait_until_location_contains (
122123 self ,
123124 expected : str ,
124- timeout : Union [ str , float , None ] = None ,
125+ timeout : Optional [ timedelta ] = None ,
125126 message : Optional [str ] = None ,
126127 ):
127128 """Waits until the current URL contains ``expected``.
@@ -149,7 +150,7 @@ def wait_until_location_contains(
149150 def wait_until_location_does_not_contain (
150151 self ,
151152 location : str ,
152- timeout : Union [ str , float , None ] = None ,
153+ timeout : Optional [ timedelta ] = None ,
153154 message : Optional [str ] = None ,
154155 ):
155156 """Waits until the current URL does not contains ``location``.
@@ -177,7 +178,7 @@ def wait_until_location_does_not_contain(
177178 def wait_until_page_contains (
178179 self ,
179180 text : str ,
180- timeout : Union [ str , float , None ] = None ,
181+ timeout : Optional [ timedelta ] = None ,
181182 error : Optional [str ] = None ,
182183 ):
183184 """Waits until ``text`` appears on the current page.
@@ -199,7 +200,7 @@ def wait_until_page_contains(
199200 def wait_until_page_does_not_contain (
200201 self ,
201202 text : str ,
202- timeout : Union [ str , float , None ] = None ,
203+ timeout : Optional [ timedelta ] = None ,
203204 error : Optional [str ] = None ,
204205 ):
205206 """Waits until ``text`` disappears from the current page.
@@ -221,7 +222,7 @@ def wait_until_page_does_not_contain(
221222 def wait_until_page_contains_element (
222223 self ,
223224 locator : str ,
224- timeout : Union [ str , float , None ] = None ,
225+ timeout : Optional [ timedelta ] = None ,
225226 error : Optional [str ] = None ,
226227 limit : Optional [int ] = None ,
227228 ):
@@ -259,7 +260,7 @@ def wait_until_page_contains_element(
259260 def wait_until_page_does_not_contain_element (
260261 self ,
261262 locator : str ,
262- timeout : Union [ str , float , None ] = None ,
263+ timeout : Optional [ timedelta ] = None ,
263264 error : Optional [str ] = None ,
264265 limit : Optional [int ] = None ,
265266 ):
@@ -297,7 +298,7 @@ def wait_until_page_does_not_contain_element(
297298 def wait_until_element_is_visible (
298299 self ,
299300 locator : str ,
300- timeout : Union [ str , float , None ] = None ,
301+ timeout : Optional [ timedelta ] = None ,
301302 error : Optional [str ] = None ,
302303 ):
303304 """Waits until the element ``locator`` is visible.
@@ -320,7 +321,7 @@ def wait_until_element_is_visible(
320321 def wait_until_element_is_not_visible (
321322 self ,
322323 locator : str ,
323- timeout : Union [ str , float , None ] = None ,
324+ timeout : Optional [ timedelta ] = None ,
324325 error : Optional [str ] = None ,
325326 ):
326327 """Waits until the element ``locator`` is not visible.
@@ -343,7 +344,7 @@ def wait_until_element_is_not_visible(
343344 def wait_until_element_is_enabled (
344345 self ,
345346 locator : str ,
346- timeout : Union [ str , float , None ] = None ,
347+ timeout : Optional [ timedelta ] = None ,
347348 error : Optional [str ] = None ,
348349 ):
349350 """Waits until the element ``locator`` is enabled.
@@ -372,7 +373,7 @@ def wait_until_element_contains(
372373 self ,
373374 locator : str ,
374375 text : str ,
375- timeout : Union [ str , float , None ] = None ,
376+ timeout : Optional [ timedelta ] = None ,
376377 error : Optional [str ] = None ,
377378 ):
378379 """Waits until the element ``locator`` contains ``text``.
@@ -396,7 +397,7 @@ def wait_until_element_does_not_contain(
396397 self ,
397398 locator : str ,
398399 text : str ,
399- timeout : Union [ str , float , None ] = None ,
400+ timeout : Optional [ timedelta ] = None ,
400401 error : Optional [str ] = None ,
401402 ):
402403 """Waits until the element ``locator`` does not contain ``text``.
0 commit comments