@@ -134,8 +134,8 @@ def assert_element(context, selector):
134
134
@step ('Assert text "{text}" in \' {selector}\' ' )
135
135
@step ("Text in '{selector}' should contain '{text}'" )
136
136
@step ('Text in "{selector}" should contain "{text}"' )
137
- @step ('Text in "{selector}" should contain \' {text}\' ' )
138
137
@step ("Text in '{selector}' should contain \" {text}\" " )
138
+ @step ('Text in "{selector}" should contain \' {text}\' ' )
139
139
def assert_text_in_element (context , text , selector ):
140
140
sb = context .sb
141
141
text = normalize_text (text )
@@ -160,8 +160,8 @@ def assert_text(context, text):
160
160
@step ('Assert exact text "{text}" in \' {selector}\' ' )
161
161
@step ("Text in '{selector}' should be '{text}'" )
162
162
@step ('Text in "{selector}" should be "{text}"' )
163
- @step ('Text in "{selector}" should be \' {text}\' ' )
164
163
@step ("Text in '{selector}' should be \" {text}\" " )
164
+ @step ('Text in "{selector}" should be \' {text}\' ' )
165
165
def assert_exact_text (context , text , selector ):
166
166
sb = context .sb
167
167
text = normalize_text (text )
@@ -172,8 +172,8 @@ def assert_exact_text(context, text, selector):
172
172
@step ('Highlight "{selector}"' )
173
173
@step ("Highlight element '{selector}'" )
174
174
@step ('Highlight element "{selector}"' )
175
- @step ("User uses JS to highlight '{selector}'" )
176
- @step ('User uses JS to highlight "{selector}"' )
175
+ @step ("Use JS to highlight '{selector}'" )
176
+ @step ('Use JS to highlight "{selector}"' )
177
177
def highlight_element (context , selector ):
178
178
sb = context .sb
179
179
sb .highlight (selector )
@@ -192,13 +192,37 @@ def click_link(context, link):
192
192
@step ('JS click "{selector}"' )
193
193
@step ("JS click element '{selector}'" )
194
194
@step ('JS click element "{selector}"' )
195
- @step ("User uses JS to click '{selector}'" )
196
- @step ('User uses JS to click "{selector}"' )
195
+ @step ("Use JS to click '{selector}'" )
196
+ @step ('Use JS to click "{selector}"' )
197
197
def js_click (context , selector ):
198
198
sb = context .sb
199
199
sb .js_click (selector )
200
200
201
201
202
+ @step ("Save screenshot as '{name}'" )
203
+ @step ('Save screenshot as "{name}"' )
204
+ @step ("User saves screenshot as '{name}'" )
205
+ @step ('User saves screenshot as "{name}"' )
206
+ def save_screenshot_as (context , name ):
207
+ sb = context .sb
208
+ name = normalize_text (name )
209
+ sb .save_screenshot (name )
210
+
211
+
212
+ @step ("Save screenshot to '{folder}' as '{name}'" )
213
+ @step ('Save screenshot to "{folder}" as "{name}"' )
214
+ @step ("Save screenshot to '{folder}' as \" {name}\" " )
215
+ @step ('Save screenshot to "{folder}" as \' {name}\' ' )
216
+ @step ("User saves screenshot to '{folder}' as '{name}'" )
217
+ @step ('User saves screenshot to "{folder}" as "{name}"' )
218
+ @step ("User saves screenshot to '{folder}' as \" {name}\" " )
219
+ @step ('User saves screenshot to "{folder}" as \' {name}\' ' )
220
+ def save_screenshot_to_folder_as (context , name , folder ):
221
+ sb = context .sb
222
+ name = normalize_text (name )
223
+ sb .save_screenshot (name , folder )
224
+
225
+
202
226
@step ("Save screenshot to logs" )
203
227
@step ("Save a screenshot to the logs" )
204
228
@step ("User saves screenshot to logs" )
@@ -233,36 +257,6 @@ def go_forward(context):
233
257
sb .go_forward ()
234
258
235
259
236
- @step ("JS type '{text}' in '{selector}'" )
237
- @step ('JS type "{text}" in "{selector}"' )
238
- @step ("JS type '{text}' in \" {selector}\" " )
239
- @step ('JS type "{text}" in \' {selector}\' ' )
240
- @step ("JS type '{text}' into '{selector}'" )
241
- @step ('JS type "{text}" into "{selector}"' )
242
- @step ("JS type '{text}' into \" {selector}\" " )
243
- @step ('JS type "{text}" into \' {selector}\' ' )
244
- @step ("JS type text '{text}' in '{selector}'" )
245
- @step ('JS type text "{text}" in "{selector}"' )
246
- @step ("JS type text '{text}' in \" {selector}\" " )
247
- @step ('JS type text "{text}" in \' {selector}\' ' )
248
- @step ("JS type text '{text}' into '{selector}'" )
249
- @step ('JS type text "{text}" into "{selector}"' )
250
- @step ("JS type text '{text}' into \" {selector}\" " )
251
- @step ('JS type text "{text}" into \' {selector}\' ' )
252
- @step ("User uses JS to type '{text}' in '{selector}'" )
253
- @step ('User uses JS to type "{text}" in "{selector}"' )
254
- @step ("User uses JS to type '{text}' in \" {selector}\" " )
255
- @step ('User uses JS to type "{text}" in \' {selector}\' ' )
256
- @step ("User uses JS to type '{text}' into '{selector}'" )
257
- @step ('User uses JS to type "{text}" into "{selector}"' )
258
- @step ("User uses JS to type '{text}' into \" {selector}\" " )
259
- @step ('User uses JS to type "{text}" into \' {selector}\' ' )
260
- def js_type (context , text , selector ):
261
- sb = context .sb
262
- text = normalize_text (text )
263
- sb .js_type (selector , text )
264
-
265
-
266
260
@step ("Set value of '{selector}' to '{text}'" )
267
261
@step ('Set value of "{selector}" to "{text}"' )
268
262
@step ("Set value of \" {selector}\" to '{text}'" )
@@ -271,7 +265,7 @@ def js_type(context, text, selector):
271
265
@step ('User sets value of "{selector}" to "{text}"' )
272
266
@step ("User sets value of \" {selector}\" to '{text}'" )
273
267
@step ('User sets value of \' {selector}\' to "{text}"' )
274
- def set_value (context , text , selector ):
268
+ def set_value (context , selector , text ):
275
269
sb = context .sb
276
270
text = normalize_text (text )
277
271
sb .set_value (selector , text )
@@ -627,8 +621,8 @@ def clear_session_storage(context):
627
621
628
622
@step ("JS click all '{selector}'" )
629
623
@step ('JS click all "{selector}"' )
630
- @step ("User uses JS to click all '{selector}'" )
631
- @step ('User uses JS to click all "{selector}"' )
624
+ @step ("Use JS to click all '{selector}'" )
625
+ @step ('Use JS to click all "{selector}"' )
632
626
def js_click_all (context , selector ):
633
627
sb = context .sb
634
628
sb .js_click_all (selector )
@@ -781,8 +775,8 @@ def assert_attribute_has_value(context, selector, attribute, value):
781
775
782
776
@step ("Show file choosers" )
783
777
@step ("Show hidden file choosers" )
784
- @step ("User uses JS to show file choosers" )
785
- @step ("User uses JS to show hidden file choosers" )
778
+ @step ("Use JS to show file choosers" )
779
+ @step ("Use JS to show hidden file choosers" )
786
780
def show_file_choosers (context ):
787
781
sb = context .sb
788
782
sb .show_file_choosers ()
@@ -924,10 +918,42 @@ def open_new_window(context):
924
918
sb .open_new_window ()
925
919
926
920
921
+ @step ("Accept alert" )
922
+ @step ("User accepts alert" )
923
+ def accept_alert (context ):
924
+ sb = context .sb
925
+ sb .accept_alert ()
926
+
927
+
928
+ @step ("Dismiss alert" )
929
+ @step ("User dismisses alert" )
930
+ def dismiss_alert (context ):
931
+ sb = context .sb
932
+ sb .dismiss_alert ()
933
+
934
+
935
+ @step ("Assert URL '{url}'" )
936
+ @step ('Assert URL "{url}"' )
937
+ @step ("The URL should be '{url}'" )
938
+ @step ('The URL should be "{url}"' )
939
+ def assert_url (context , url ):
940
+ sb = context .sb
941
+ url = normalize_text (url )
942
+ sb .assert_url (url )
943
+
944
+
945
+ @step ("Assert URL contains '{substring}'" )
946
+ @step ('Assert URL contains "{substring}"' )
947
+ @step ("The URL should contain '{substring}'" )
948
+ @step ('The URL should contain "{substring}"' )
949
+ def assert_url_contains (context , substring ):
950
+ sb = context .sb
951
+ substring = normalize_text (substring )
952
+ sb .assert_url_contains (substring )
953
+
954
+
927
955
@step ("Hover '{selector}'" )
928
956
@step ('Hover "{selector}"' )
929
- @step ("Hover on '{selector}'" )
930
- @step ('Hover on "{selector}"' )
931
957
@step ("Hover over '{selector}'" )
932
958
@step ('Hover over "{selector}"' )
933
959
@step ("Hover element '{selector}'" )
@@ -958,35 +984,109 @@ def context_click(context, selector):
958
984
sb .context_click (selector )
959
985
960
986
961
- @step ("Accept alert" )
962
- @step ("User accepts alert" )
963
- def accept_alert (context ):
987
+ @step ("JS type '{text}' in '{selector}'" )
988
+ @step ('JS type "{text}" in "{selector}"' )
989
+ @step ("JS type '{text}' in \" {selector}\" " )
990
+ @step ('JS type "{text}" in \' {selector}\' ' )
991
+ @step ("JS type '{text}' into '{selector}'" )
992
+ @step ('JS type "{text}" into "{selector}"' )
993
+ @step ("JS type '{text}' into \" {selector}\" " )
994
+ @step ('JS type "{text}" into \' {selector}\' ' )
995
+ @step ("JS type text '{text}' in '{selector}'" )
996
+ @step ('JS type text "{text}" in "{selector}"' )
997
+ @step ("JS type text '{text}' in \" {selector}\" " )
998
+ @step ('JS type text "{text}" in \' {selector}\' ' )
999
+ @step ("JS type text '{text}' into '{selector}'" )
1000
+ @step ('JS type text "{text}" into "{selector}"' )
1001
+ @step ("JS type text '{text}' into \" {selector}\" " )
1002
+ @step ('JS type text "{text}" into \' {selector}\' ' )
1003
+ @step ("Use JS to type '{text}' in '{selector}'" )
1004
+ @step ('Use JS to type "{text}" in "{selector}"' )
1005
+ @step ("Use JS to type '{text}' in \" {selector}\" " )
1006
+ @step ('Use JS to type "{text}" in \' {selector}\' ' )
1007
+ @step ("Use JS to type '{text}' into '{selector}'" )
1008
+ @step ('Use JS to type "{text}" into "{selector}"' )
1009
+ @step ("Use JS to type '{text}' into \" {selector}\" " )
1010
+ @step ('Use JS to type "{text}" into \' {selector}\' ' )
1011
+ def js_type (context , text , selector ):
964
1012
sb = context .sb
965
- sb .accept_alert ()
1013
+ text = normalize_text (text )
1014
+ sb .js_type (selector , text )
966
1015
967
1016
968
- @step ("Dismiss alert" )
969
- @step ("User dismisses alert" )
970
- def dismiss_alert (context ):
1017
+ @step ("jQuery click '{selector}'" )
1018
+ @step ('jQuery click "{selector}"' )
1019
+ @step ("jQuery click element '{selector}'" )
1020
+ @step ('jQuery click element "{selector}"' )
1021
+ @step ("Use jQuery to click '{selector}'" )
1022
+ @step ('Use jQuery to click "{selector}"' )
1023
+ def jquery_click (context , selector ):
1024
+ sb = context .sb
1025
+ sb .jquery_click (selector )
1026
+
1027
+
1028
+ @step ("jQuery click all '{selector}'" )
1029
+ @step ('jQuery click all "{selector}"' )
1030
+ @step ("Use jQuery to click all '{selector}'" )
1031
+ @step ('Use jQuery to click all "{selector}"' )
1032
+ def jquery_click_all (context , selector ):
1033
+ sb = context .sb
1034
+ sb .jquery_click_all (selector )
1035
+
1036
+
1037
+ @step ("jQuery type '{text}' in '{selector}'" )
1038
+ @step ('jQuery type "{text}" in "{selector}"' )
1039
+ @step ("jQuery type '{text}' in \" {selector}\" " )
1040
+ @step ('jQuery type "{text}" in \' {selector}\' ' )
1041
+ @step ("jQuery type '{text}' into '{selector}'" )
1042
+ @step ('jQuery type "{text}" into "{selector}"' )
1043
+ @step ("jQuery type '{text}' into \" {selector}\" " )
1044
+ @step ('jQuery type "{text}" into \' {selector}\' ' )
1045
+ @step ("jQuery type text '{text}' in '{selector}'" )
1046
+ @step ('jQuery type text "{text}" in "{selector}"' )
1047
+ @step ("jQuery type text '{text}' in \" {selector}\" " )
1048
+ @step ('jQuery type text "{text}" in \' {selector}\' ' )
1049
+ @step ("jQuery type text '{text}' into '{selector}'" )
1050
+ @step ('jQuery type text "{text}" into "{selector}"' )
1051
+ @step ("jQuery type text '{text}' into \" {selector}\" " )
1052
+ @step ('jQuery type text "{text}" into \' {selector}\' ' )
1053
+ @step ("Use jQuery to type '{text}' in '{selector}'" )
1054
+ @step ('Use jQuery to type "{text}" in "{selector}"' )
1055
+ @step ("Use jQuery to type '{text}' in \" {selector}\" " )
1056
+ @step ('Use jQuery to type "{text}" in \' {selector}\' ' )
1057
+ @step ("Use jQuery to type '{text}' into '{selector}'" )
1058
+ @step ('Use jQuery to type "{text}" into "{selector}"' )
1059
+ @step ("Use jQuery to type '{text}' into \" {selector}\" " )
1060
+ @step ('Use jQuery to type "{text}" into \' {selector}\' ' )
1061
+ def jquery_type (context , text , selector ):
971
1062
sb = context .sb
972
- sb .dismiss_alert ()
1063
+ text = normalize_text (text )
1064
+ sb .jquery_type (selector , text )
973
1065
974
1066
975
- @step ("Assert URL '{url }'" )
976
- @step ('Assert URL "{url }"' )
977
- @step ("The URL should be '{url}' " )
978
- @step ('The URL should be "{url}" ' )
979
- def assert_url (context , url ):
1067
+ @step ("Find '{selector}' and set {attribute} to '{value }'" )
1068
+ @step ('Find "{selector}" and set {attribute} to "{value }"' )
1069
+ @step ("Find '{selector}' and set {attribute} to \" {value} \" " )
1070
+ @step ('Find "{selector}" and set {attribute} to \' {value} \' ' )
1071
+ def set_attribute (context , selector , attribute , value ):
980
1072
sb = context .sb
981
- url = normalize_text (url )
982
- sb .assert_url (url )
1073
+ value = normalize_text (value )
1074
+ if attribute .startswith ("'" ) or attribute .startswith ('"' ):
1075
+ attribute = attribute [1 :]
1076
+ if attribute .endswith ("'" ) or attribute .endswith ('"' ):
1077
+ attribute = attribute [:- 1 ]
1078
+ sb .set_attribute (selector , attribute , value )
983
1079
984
1080
985
- @step ("Assert URL contains '{substring }'" )
986
- @step ('Assert URL contains "{substring }"' )
987
- @step ("The URL should contain '{substring}' " )
988
- @step ('The URL should contain "{substring}" ' )
989
- def assert_url_contains (context , substring ):
1081
+ @step ("Find all '{selector}' and set {attribute} to '{value }'" )
1082
+ @step ('Find all "{selector}" and set {attribute} to "{value }"' )
1083
+ @step ("Find all '{selector}' and set {attribute} to \" {value} \" " )
1084
+ @step ('Find all "{selector}" and set {attribute} to \' {value} \' ' )
1085
+ def set_attributes (context , selector , attribute , value ):
990
1086
sb = context .sb
991
- substring = normalize_text (substring )
992
- sb .assert_url_contains (substring )
1087
+ value = normalize_text (value )
1088
+ if attribute .startswith ("'" ) or attribute .startswith ('"' ):
1089
+ attribute = attribute [1 :]
1090
+ if attribute .endswith ("'" ) or attribute .endswith ('"' ):
1091
+ attribute = attribute [:- 1 ]
1092
+ sb .set_attributes (selector , attribute , value )
0 commit comments