14
14
# See the License for the specific language governing permissions and
15
15
# limitations under the License.
16
16
from collections import namedtuple
17
- from typing import List , Optional
17
+ from typing import List , Optional , Tuple
18
18
19
19
from robot .utils import plural_or_not
20
20
from selenium .webdriver .common .action_chains import ActionChains
@@ -51,7 +51,11 @@ def get_webelements(self, locator: str) -> List[WebElement]:
51
51
52
52
@keyword
53
53
def element_should_contain (
54
- self , locator : str , expected : str , message : Optional [str ] = None , ignore_case : bool = False
54
+ self ,
55
+ locator : str ,
56
+ expected : str ,
57
+ message : Optional [str ] = None ,
58
+ ignore_case : bool = False ,
55
59
):
56
60
"""Verifies that element ``locator`` contains text ``expected``.
57
61
@@ -85,7 +89,11 @@ def element_should_contain(
85
89
86
90
@keyword
87
91
def element_should_not_contain (
88
- self , locator : str , expected : str , message : Optional [str ] = None , ignore_case : bool = False
92
+ self ,
93
+ locator : str ,
94
+ expected : str ,
95
+ message : Optional [str ] = None ,
96
+ ignore_case : bool = False ,
89
97
):
90
98
"""Verifies that element ``locator`` does not contain text ``expected``.
91
99
@@ -133,7 +141,11 @@ def page_should_contain(self, text: str, loglevel: str = "TRACE"):
133
141
134
142
@keyword
135
143
def page_should_contain_element (
136
- self , locator : str , message : Optional [str ] = None , loglevel : Optional [str ] = "TRACE" , limit : Optional [int ] = None
144
+ self ,
145
+ locator : str ,
146
+ message : Optional [str ] = None ,
147
+ loglevel : Optional [str ] = "TRACE" ,
148
+ limit : Optional [int ] = None ,
137
149
):
138
150
"""Verifies that element ``locator`` is found on the current page.
139
151
@@ -189,7 +201,9 @@ def page_should_not_contain(self, text: str, loglevel: str = "TRACE"):
189
201
self .info (f"Current page does not contain text '{ text } '." )
190
202
191
203
@keyword
192
- def page_should_not_contain_element (self , locator : str , message : Optional [str ] = None , loglevel : str = "TRACE" ):
204
+ def page_should_not_contain_element (
205
+ self , locator : str , message : Optional [str ] = None , loglevel : str = "TRACE"
206
+ ):
193
207
"""Verifies that element ``locator`` is not found on the current page.
194
208
195
209
See the `Locating elements` section for details about the locator
@@ -284,7 +298,9 @@ def element_should_be_visible(self, locator: str, message: Optional[str] = None)
284
298
self .info (f"Element '{ locator } ' is displayed." )
285
299
286
300
@keyword
287
- def element_should_not_be_visible (self , locator : str , message : Optional [str ] = None ):
301
+ def element_should_not_be_visible (
302
+ self , locator : str , message : Optional [str ] = None
303
+ ):
288
304
"""Verifies that the element identified by ``locator`` is NOT visible.
289
305
290
306
Passes if the element does not exists. See `Element Should Be Visible`
@@ -302,7 +318,11 @@ def element_should_not_be_visible(self, locator: str, message: Optional[str] = N
302
318
303
319
@keyword
304
320
def element_text_should_be (
305
- self , locator : str , expected : str , message : Optional [str ] = None , ignore_case : bool = False
321
+ self ,
322
+ locator : str ,
323
+ expected : str ,
324
+ message : Optional [str ] = None ,
325
+ ignore_case : bool = False ,
306
326
):
307
327
"""Verifies that element ``locator`` contains exact the text ``expected``.
308
328
@@ -334,7 +354,11 @@ def element_text_should_be(
334
354
335
355
@keyword
336
356
def element_text_should_not_be (
337
- self , locator : str , not_expected : str , message : Optional [str ] = None , ignore_case : bool = False
357
+ self ,
358
+ locator : str ,
359
+ not_expected : str ,
360
+ message : Optional [str ] = None ,
361
+ ignore_case : bool = False ,
338
362
):
339
363
"""Verifies that element ``locator`` does not contain exact the text ``not_expected``.
340
364
@@ -419,7 +443,7 @@ def get_horizontal_position(self, locator: str) -> int:
419
443
return self .find_element (locator ).location ["x" ]
420
444
421
445
@keyword
422
- def get_element_size (self , locator : str ) -> int :
446
+ def get_element_size (self , locator : str ) -> Tuple [ int , int ] :
423
447
"""Returns width and height of the element identified by ``locator``.
424
448
425
449
See the `Locating elements` section for details about the locator
@@ -571,7 +595,9 @@ def click_link(self, locator: str, modifier: Optional[str] = False):
571
595
self ._click_with_modifier (locator , ["link" , "link" ], modifier )
572
596
573
597
@keyword
574
- def click_element (self , locator : str , modifier : Optional [str ] = False , action_chain : bool = False ):
598
+ def click_element (
599
+ self , locator : str , modifier : Optional [str ] = False , action_chain : bool = False
600
+ ):
575
601
"""Click the element identified by ``locator``.
576
602
577
603
See the `Locating elements` section for details about the locator
@@ -953,7 +979,9 @@ def mouse_down_on_link(self, locator: str):
953
979
action .click_and_hold (element ).perform ()
954
980
955
981
@keyword
956
- def page_should_contain_link (self , locator : str , message : Optional [str ] = None , loglevel : str = "TRACE" ):
982
+ def page_should_contain_link (
983
+ self , locator : str , message : Optional [str ] = None , loglevel : str = "TRACE"
984
+ ):
957
985
"""Verifies link identified by ``locator`` is found from current page.
958
986
959
987
See the `Locating elements` section for details about the locator
@@ -966,7 +994,9 @@ def page_should_contain_link(self, locator: str, message: Optional[str] = None,
966
994
self .assert_page_contains (locator , "link" , message , loglevel )
967
995
968
996
@keyword
969
- def page_should_not_contain_link (self , locator : str , message : Optional [str ] = None , loglevel : str = "TRACE" ):
997
+ def page_should_not_contain_link (
998
+ self , locator : str , message : Optional [str ] = None , loglevel : str = "TRACE"
999
+ ):
970
1000
"""Verifies link identified by ``locator`` is not found from current page.
971
1001
972
1002
See the `Locating elements` section for details about the locator
@@ -991,7 +1021,9 @@ def mouse_down_on_image(self, locator: str):
991
1021
action .click_and_hold (element ).perform ()
992
1022
993
1023
@keyword
994
- def page_should_contain_image (self , locator : str , message : Optional [str ] = None , loglevel : str = "TRACE" ):
1024
+ def page_should_contain_image (
1025
+ self , locator : str , message : Optional [str ] = None , loglevel : str = "TRACE"
1026
+ ):
995
1027
"""Verifies image identified by ``locator`` is found from current page.
996
1028
997
1029
See the `Locating elements` section for details about the locator
@@ -1004,7 +1036,9 @@ def page_should_contain_image(self, locator: str, message: Optional[str] = None,
1004
1036
self .assert_page_contains (locator , "image" , message , loglevel )
1005
1037
1006
1038
@keyword
1007
- def page_should_not_contain_image (self , locator : str , message : Optional [str ] = None , loglevel : str = "TRACE" ):
1039
+ def page_should_not_contain_image (
1040
+ self , locator : str , message : Optional [str ] = None , loglevel : str = "TRACE"
1041
+ ):
1008
1042
"""Verifies image identified by ``locator`` is not found from current page.
1009
1043
1010
1044
See the `Locating elements` section for details about the locator
@@ -1033,7 +1067,9 @@ def get_element_count(self, locator: str) -> int:
1033
1067
return len (self .find_elements (locator ))
1034
1068
1035
1069
@keyword
1036
- def add_location_strategy (self , strategy_name : str , strategy_keyword : str , persist : bool = False ):
1070
+ def add_location_strategy (
1071
+ self , strategy_name : str , strategy_keyword : str , persist : bool = False
1072
+ ):
1037
1073
"""Adds a custom location strategy.
1038
1074
1039
1075
See `Custom locators` for information on how to create and use
0 commit comments