@@ -74,8 +74,7 @@ def _predicate(driver: WebDriver):
7474
7575
7676def presence_of_element_located (locator : tuple [str , str ]) -> Callable [[WebDriverOrWebElement ], WebElement ]:
77- """An expectation for checking that an element is present on the DOM of a
78- page. This does not necessarily mean that the element is visible.
77+ """Check that an element is present on the DOM (not necessarily visible).
7978
8079 Args:
8180 locator: Used to find the element.
@@ -97,8 +96,7 @@ def _predicate(driver: WebDriverOrWebElement):
9796
9897
9998def url_contains (url : str ) -> Callable [[WebDriver ], bool ]:
100- """An expectation for checking that the current url contains a case-
101- sensitive substring.
99+ """Check that the current url contains a case-sensitive substring.
102100
103101 Args:
104102 url: The fragment of url expected.
@@ -149,8 +147,7 @@ def _predicate(driver: WebDriver):
149147
150148
151149def url_changes (url : str ) -> Callable [[WebDriver ], bool ]:
152- """An expectation for checking the current url is different than a given
153- string.
150+ """Check that the current url differs from a given string.
154151
155152 Args:
156153 url: The expected url, which must not be an exact match.
@@ -168,9 +165,7 @@ def _predicate(driver: WebDriver):
168165def visibility_of_element_located (
169166 locator : tuple [str , str ],
170167) -> Callable [[WebDriverOrWebElement ], Union [Literal [False ], WebElement ]]:
171- """An expectation for checking that an element is present on the DOM of a
172- page and visible. Visibility means that the element is not only displayed
173- but also has a height and width that is greater than 0.
168+ """Check that an element is present on the DOM and visible (has size).
174169
175170 Args:
176171 locator: Used to find the element.
@@ -195,11 +190,7 @@ def _predicate(driver: WebDriverOrWebElement):
195190
196191
197192def visibility_of (element : WebElement ) -> Callable [[Any ], Union [Literal [False ], WebElement ]]:
198- """An expectation for checking that an element, known to be present on the
199- DOM of a page, is visible.
200-
201- Visibility means that the element is not only displayed but also has
202- a height and width that is greater than 0.
193+ """Check that an element is visible (present on DOM and has size).
203194
204195 Args:
205196 element: The WebElement to check.
@@ -221,8 +212,7 @@ def _predicate(_):
221212
222213
223214def _element_if_visible (element : WebElement , visibility : bool = True ) -> Union [Literal [False ], WebElement ]:
224- """An expectation for checking that an element, known to be present on the
225- DOM of a page, is of the expected visibility.
215+ """Check if an element has the expected visibility state.
226216
227217 Args:
228218 element: The WebElement to check.
@@ -235,8 +225,7 @@ def _element_if_visible(element: WebElement, visibility: bool = True) -> Union[L
235225
236226
237227def presence_of_all_elements_located (locator : tuple [str , str ]) -> Callable [[WebDriverOrWebElement ], list [WebElement ]]:
238- """An expectation for checking that there is at least one element present
239- on a web page.
228+ """Check that all elements matching the locator are present on the DOM.
240229
241230 Args:
242231 locator: Used to find the element.
@@ -258,8 +247,7 @@ def _predicate(driver: WebDriverOrWebElement):
258247
259248
260249def visibility_of_any_elements_located (locator : tuple [str , str ]) -> Callable [[WebDriverOrWebElement ], list [WebElement ]]:
261- """An expectation for checking that there is at least one element visible
262- on a web page.
250+ """Check that at least one element is visible on the web page.
263251
264252 Args:
265253 locator: Used to find the element.
@@ -283,9 +271,7 @@ def _predicate(driver: WebDriverOrWebElement):
283271def visibility_of_all_elements_located (
284272 locator : tuple [str , str ],
285273) -> Callable [[WebDriverOrWebElement ], Union [list [WebElement ], Literal [False ]]]:
286- """An expectation for checking that all elements are present on the DOM of
287- a page and visible. Visibility means that the elements are not only
288- displayed but also has a height and width that is greater than 0.
274+ """Check that all elements are present on the DOM and visible (have size).
289275
290276 Args:
291277 locator: Used to find the elements.
@@ -314,8 +300,7 @@ def _predicate(driver: WebDriverOrWebElement):
314300
315301
316302def text_to_be_present_in_element (locator : tuple [str , str ], text_ : str ) -> Callable [[WebDriverOrWebElement ], bool ]:
317- """An expectation for checking if the given text is present in the
318- specified element.
303+ """Check that the given text is present in the specified element.
319304
320305 Args:
321306 locator: Used to find the element.
@@ -346,8 +331,7 @@ def _predicate(driver: WebDriverOrWebElement):
346331def text_to_be_present_in_element_value (
347332 locator : tuple [str , str ], text_ : str
348333) -> Callable [[WebDriverOrWebElement ], bool ]:
349- """An expectation for checking if the given text is present in the
350- element's value.
334+ """Check that the given text is present in the element's value.
351335
352336 Args:
353337 locator: Used to find the element.
@@ -380,8 +364,7 @@ def _predicate(driver: WebDriverOrWebElement):
380364def text_to_be_present_in_element_attribute (
381365 locator : tuple [str , str ], attribute_ : str , text_ : str
382366) -> Callable [[WebDriverOrWebElement ], bool ]:
383- """An expectation for checking if the given text is present in the
384- element's attribute.
367+ """Check that the given text is present in the element's attribute.
385368
386369 Args:
387370 locator: Used to find the element.
@@ -415,11 +398,7 @@ def _predicate(driver: WebDriverOrWebElement):
415398def frame_to_be_available_and_switch_to_it (
416399 locator : Union [tuple [str , str ], str , WebElement ],
417400) -> Callable [[WebDriver ], bool ]:
418- """An expectation for checking whether the given frame is available to
419- switch to.
420-
421- If the frame is available it switches the given driver to the
422- specified frame.
401+ """Check that the given frame is available and switch to it.
423402
424403 Args:
425404 locator: Used to find the frame.
@@ -449,8 +428,7 @@ def _predicate(driver: WebDriver):
449428def invisibility_of_element_located (
450429 locator : Union [WebElement , tuple [str , str ]],
451430) -> Callable [[WebDriverOrWebElement ], Union [WebElement , bool ]]:
452- """An Expectation for checking that an element is either invisible or not
453- present on the DOM.
431+ """Check that an element is either invisible or not present on the DOM.
454432
455433 Args:
456434 locator: Used to find the element.
@@ -492,8 +470,7 @@ def _predicate(driver: WebDriverOrWebElement):
492470def invisibility_of_element (
493471 element : Union [WebElement , tuple [str , str ]],
494472) -> Callable [[WebDriverOrWebElement ], Union [WebElement , bool ]]:
495- """An Expectation for checking that an element is either invisible or not
496- present on the DOM.
473+ """Check that an element is either invisible or not present on the DOM.
497474
498475 Args:
499476 element: Used to find the element.
@@ -515,8 +492,7 @@ def invisibility_of_element(
515492def element_to_be_clickable (
516493 mark : Union [WebElement , tuple [str , str ]],
517494) -> Callable [[WebDriverOrWebElement ], Union [Literal [False ], WebElement ]]:
518- """An Expectation for checking an element is visible and enabled such that
519- you can click it.
495+ """Check that an element is visible and enabled so it can be clicked.
520496
521497 Args:
522498 mark: Used to find the element.
@@ -646,8 +622,7 @@ def _predicate(_):
646622def element_located_selection_state_to_be (
647623 locator : tuple [str , str ], is_selected : bool
648624) -> Callable [[WebDriverOrWebElement ], bool ]:
649- """An expectation to locate an element and check if the selection state
650- specified is in that state.
625+ """Check that an element's selection state matches the expected state.
651626
652627 Args:
653628 locator: Used to find the element.
@@ -696,9 +671,8 @@ def _predicate(driver: WebDriver):
696671 return _predicate
697672
698673
699- def new_window_is_opened (current_handles : list [str ]) -> Callable [[WebDriver ], bool ]:
700- """An expectation that a new window will be opened and have the number of
701- windows handles increase.
674+ def new_window_is_opened (current_handles : set [str ]) -> Callable [[WebDriver ], bool ]:
675+ """Check that a new window has been opened (window handles count increased).
702676
703677 Args:
704678 current_handles: The current window handles.
@@ -719,9 +693,8 @@ def _predicate(driver: WebDriver):
719693 return _predicate
720694
721695
722- def alert_is_present () -> Callable [[WebDriver ], Union [Alert , Literal [False ]]]:
723- """An expectation for checking if an alert is currently present and
724- switching to it.
696+ def alert_is_present () -> Callable [[WebDriver ], Union [Alert , bool ]]:
697+ """Check that an alert is present and switch to it.
725698
726699 Returns:
727700 The Alert once it is located.
@@ -745,8 +718,7 @@ def _predicate(driver: WebDriver):
745718
746719
747720def element_attribute_to_include (locator : tuple [str , str ], attribute_ : str ) -> Callable [[WebDriverOrWebElement ], bool ]:
748- """An expectation for checking if the given attribute is included in the
749- specified element.
721+ """Check if the given attribute is included in the specified element.
750722
751723 Args:
752724 locator: Used to find the element.
0 commit comments