@@ -39,6 +39,11 @@ def generate_gherkin(srt_actions):
39
39
sb_actions .append ('Click "%s"' % action [1 ])
40
40
else :
41
41
sb_actions .append ("Click '%s'" % action [1 ])
42
+ elif action [0 ] == "dbclk" :
43
+ if '"' not in action [1 ]:
44
+ sb_actions .append ('Double click "%s"' % action [1 ])
45
+ else :
46
+ sb_actions .append ("Double click '%s'" % action [1 ])
42
47
elif action [0 ] == "js_cl" :
43
48
if '"' not in action [1 ]:
44
49
sb_actions .append ('JS click "%s"' % action [1 ])
@@ -49,6 +54,16 @@ def generate_gherkin(srt_actions):
49
54
sb_actions .append ('JS click all "%s"' % action [1 ])
50
55
else :
51
56
sb_actions .append ("JS click all '%s'" % action [1 ])
57
+ elif action [0 ] == "jq_cl" :
58
+ if '"' not in action [1 ]:
59
+ sb_actions .append ('jQuery click "%s"' % action [1 ])
60
+ else :
61
+ sb_actions .append ("jQuery click '%s'" % action [1 ])
62
+ elif action [0 ] == "jq_ca" :
63
+ if '"' not in action [1 ]:
64
+ sb_actions .append ('jQuery click all "%s"' % action [1 ])
65
+ else :
66
+ sb_actions .append ("jQuery click all '%s'" % action [1 ])
52
67
elif action [0 ] == "r_clk" :
53
68
if '"' not in action [1 ]:
54
69
sb_actions .append ('Context click "%s"' % action [1 ])
@@ -66,9 +81,7 @@ def generate_gherkin(srt_actions):
66
81
sb_actions .append (
67
82
"Click '%s' at (%s, %s)" % (selector , p_x , p_y )
68
83
)
69
- elif action [0 ] == "input" or action [0 ] == "js_ty" :
70
- if action [0 ] == "js_ty" :
71
- method = "js_type"
84
+ elif action [0 ] == "input" :
72
85
text = action [2 ].replace ("\n " , "\\ n" )
73
86
if '"' not in text and '"' not in action [1 ]:
74
87
sb_actions .append ('Type "%s" into "%s"' % (text , action [1 ]))
@@ -78,6 +91,34 @@ def generate_gherkin(srt_actions):
78
91
sb_actions .append ('Type "%s" into \' %s\' ' % (text , action [1 ]))
79
92
elif '"' in text and '"' in action [1 ]:
80
93
sb_actions .append ("Type '%s' into '%s'" % (text , action [1 ]))
94
+ elif action [0 ] == "js_ty" :
95
+ text = action [2 ].replace ("\n " , "\\ n" )
96
+ if '"' not in text and '"' not in action [1 ]:
97
+ sb_actions .append ('JS type "%s" in "%s"' % (text , action [1 ]))
98
+ elif '"' in text and '"' not in action [1 ]:
99
+ sb_actions .append ('JS type \' %s\' in "%s"' % (text , action [1 ]))
100
+ elif '"' not in text and '"' in action [1 ]:
101
+ sb_actions .append ('JS type "%s" in \' %s\' ' % (text , action [1 ]))
102
+ elif '"' in text and '"' in action [1 ]:
103
+ sb_actions .append ("JS type '%s' in '%s'" % (text , action [1 ]))
104
+ elif action [0 ] == "jq_ty" :
105
+ text = action [2 ].replace ("\n " , "\\ n" )
106
+ if '"' not in text and '"' not in action [1 ]:
107
+ sb_actions .append (
108
+ 'jQuery type "%s" in "%s"' % (text , action [1 ])
109
+ )
110
+ elif '"' in text and '"' not in action [1 ]:
111
+ sb_actions .append (
112
+ 'jQuery type \' %s\' in "%s"' % (text , action [1 ])
113
+ )
114
+ elif '"' not in text and '"' in action [1 ]:
115
+ sb_actions .append (
116
+ 'jQuery type "%s" in \' %s\' ' % (text , action [1 ])
117
+ )
118
+ elif '"' in text and '"' in action [1 ]:
119
+ sb_actions .append (
120
+ "jQuery type '%s' in '%s'" % (text , action [1 ])
121
+ )
81
122
elif action [0 ] == "hover" :
82
123
if '"' not in action [1 ]:
83
124
sb_actions .append ('Hover "%s"' % action [1 ])
@@ -211,26 +252,64 @@ def generate_gherkin(srt_actions):
211
252
method = "Wait for element"
212
253
if '"' not in action [1 ]:
213
254
sb_actions .append ('%s "%s"' % (method , action [1 ]))
214
- else :
255
+ elif "'" not in action [ 1 ] :
215
256
sb_actions .append ("%s '%s'" % (method , action [1 ]))
257
+ else :
258
+ sb_actions .append (
259
+ "%s '%s'" % (method , action [1 ].replace ("'" , "\\ '" ))
260
+ )
216
261
elif action [0 ] == "as_el" :
217
262
method = "Assert element"
218
263
if '"' not in action [1 ]:
219
264
sb_actions .append ('%s "%s"' % (method , action [1 ]))
220
- else :
265
+ elif "'" not in action [ 1 ] :
221
266
sb_actions .append ("%s '%s'" % (method , action [1 ]))
267
+ else :
268
+ sb_actions .append (
269
+ "%s '%s'" % (method , action [1 ].replace ("'" , "\\ '" ))
270
+ )
222
271
elif action [0 ] == "as_ep" :
223
272
method = "Assert element present"
224
273
if '"' not in action [1 ]:
225
274
sb_actions .append ('%s "%s"' % (method , action [1 ]))
226
- else :
275
+ elif "'" not in action [ 1 ] :
227
276
sb_actions .append ("%s '%s'" % (method , action [1 ]))
277
+ else :
278
+ sb_actions .append (
279
+ "%s '%s'" % (method , action [1 ].replace ("'" , "\\ '" ))
280
+ )
228
281
elif action [0 ] == "asenv" :
229
282
method = "Assert element not visible"
230
283
if '"' not in action [1 ]:
231
284
sb_actions .append ('%s "%s"' % (method , action [1 ]))
232
- else :
285
+ elif "'" not in action [ 1 ] :
233
286
sb_actions .append ("%s '%s'" % (method , action [1 ]))
287
+ else :
288
+ sb_actions .append (
289
+ "%s '%s'" % (method , action [1 ].replace ("'" , "\\ '" ))
290
+ )
291
+ elif action [0 ] == "s_at_" or action [0 ] == "s_ats" :
292
+ start = "Find"
293
+ if action [0 ] == "s_ats" :
294
+ start = "Find all"
295
+ if '"' not in action [1 ][0 ]:
296
+ sb_actions .append (
297
+ '%s "%s" and set %s to "%s"'
298
+ % (start , action [1 ][0 ], action [1 ][1 ], action [1 ][2 ])
299
+ )
300
+ elif "'" not in action [1 ][0 ]:
301
+ sb_actions .append (
302
+ "%s '%s' and set %s to \" %s\" "
303
+ % (start , action [1 ][0 ], action [1 ][1 ], action [1 ][2 ])
304
+ )
305
+ else :
306
+ sb_actions .append (
307
+ '%s "%s" and set %s to "%s")'
308
+ % (
309
+ start .replace ('"' , '\\ "' ),
310
+ action [1 ][0 ], action [1 ][1 ], action [1 ][2 ]
311
+ )
312
+ )
234
313
elif action [0 ] == "acc_a" :
235
314
sb_actions .append ("Accept alert" )
236
315
elif action [0 ] == "dis_a" :
@@ -318,6 +397,7 @@ def generate_gherkin(srt_actions):
318
397
319
398
action [1 ][0 ] = unicodedata .normalize ("NFKC" , action [1 ][0 ])
320
399
action [1 ][0 ] = action [1 ][0 ].replace ("\n " , "\\ n" )
400
+ action [1 ][0 ] = action [1 ][0 ].replace ("\u00B6 " , "" )
321
401
method = "Assert text"
322
402
if action [0 ] == "as_et" :
323
403
method = "Assert exact text"
@@ -367,6 +447,33 @@ def generate_gherkin(srt_actions):
367
447
sb_actions .append ('%s "%s"' % (method , action [1 ]))
368
448
else :
369
449
sb_actions .append ("%s '%s'" % (method , action [1 ]))
450
+ elif action [0 ] == "s_scr" :
451
+ method = "Save screenshot as"
452
+ if '"' not in action [1 ]:
453
+ sb_actions .append ('%s "%s"' % (method , action [1 ]))
454
+ else :
455
+ sb_actions .append ("%s '%s'" % (method , action [1 ]))
456
+ elif action [0 ] == "ss_tf" :
457
+ if '"' not in action [2 ] and '"' not in action [1 ]:
458
+ sb_actions .append (
459
+ 'Save screenshot to "%s" as "%s"'
460
+ % (action [2 ], action [1 ])
461
+ )
462
+ elif '"' not in action [2 ] and '"' in action [1 ]:
463
+ sb_actions .append (
464
+ 'Save screenshot to "%s" as \' %s\' '
465
+ % (action [2 ], action [1 ])
466
+ )
467
+ elif '"' in action [2 ] and '"' not in action [1 ]:
468
+ sb_actions .append (
469
+ 'Save screenshot to \' %s\' as "%s"'
470
+ % (action [2 ], action [1 ])
471
+ )
472
+ elif '"' in action [2 ] and '"' in action [1 ]:
473
+ sb_actions .append (
474
+ "Save screenshot to '%s' as '%s'"
475
+ % (action [2 ], action [1 ])
476
+ )
370
477
elif action [0 ] == "ss_tl" :
371
478
sb_actions .append ("Save screenshot to logs" )
372
479
elif action [0 ] == "sh_fc" :
0 commit comments