Skip to content

Commit eb2a33d

Browse files
committed
Update Recorder script generation
1 parent c251e5a commit eb2a33d

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

sbase/steps.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,3 +612,29 @@ def assert_title_contains(context, substring):
612612
sb = context.sb
613613
substring = normalize_text(substring)
614614
sb.assert_title_contains(substring)
615+
616+
617+
@step("Hover '{selector}'")
618+
@step('Hover "{selector}"')
619+
@step("Hover on '{selector}'")
620+
@step('Hover on "{selector}"')
621+
@step("Hover over '{selector}'")
622+
@step('Hover over "{selector}"')
623+
@step("Hover element '{selector}'")
624+
@step('Hover element "{selector}"')
625+
def hover(context, selector):
626+
sb = context.sb
627+
sb.hover(selector)
628+
629+
630+
@step("Context click '{selector}'")
631+
@step('Context click "{selector}"')
632+
@step("Context click element '{selector}'")
633+
@step('Context click element "{selector}"')
634+
@step("Right click '{selector}'")
635+
@step('Right click "{selector}"')
636+
@step("Right click element '{selector}'")
637+
@step('Right click element "{selector}"')
638+
def context_click(context, selector):
639+
sb = context.sb
640+
sb.context_click(selector)

seleniumbase/behave/behave_helper.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ def generate_gherkin(srt_actions):
5454
sb_actions.append('JS click all "%s"' % action[1])
5555
else:
5656
sb_actions.append("JS click all '%s'" % action[1])
57+
elif action[0] == "r_clk":
58+
if '"' not in action[1]:
59+
sb_actions.append('Context click "%s"' % action[1])
60+
else:
61+
sb_actions.append("Context click '%s'" % action[1])
5762
elif action[0] == "canva":
5863
selector = action[1][0]
5964
p_x = action[1][1]
@@ -78,6 +83,11 @@ def generate_gherkin(srt_actions):
7883
sb_actions.append('Into \'%s\' type "%s"' % (action[1], text))
7984
elif '"' in action[1] and '"' in text:
8085
sb_actions.append("Into '%s' type '%s'" % (action[1], text))
86+
elif action[0] == "hover":
87+
if '"' not in action[1]:
88+
sb_actions.append('Hover "%s"' % action[1])
89+
else:
90+
sb_actions.append("Hover '%s'" % action[1])
8191
elif action[0] == "e_mfa":
8292
text = action[2].replace("\n", "\\n")
8393
if '"' not in action[1] and '"' not in text:

seleniumbase/fixtures/base_case.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4311,6 +4311,7 @@ def __process_recorded_actions(self):
43114311
ext_actions.append("js_cl")
43124312
ext_actions.append("js_ca")
43134313
ext_actions.append("js_ty")
4314+
ext_actions.append("r_clk")
43144315
ext_actions.append("as_el")
43154316
ext_actions.append("as_ep")
43164317
ext_actions.append("asenv")
@@ -4330,6 +4331,7 @@ def __process_recorded_actions(self):
43304331
ext_actions.append("sw_pf")
43314332
ext_actions.append("s_c_f")
43324333
ext_actions.append("s_c_d")
4334+
ext_actions.append("hover")
43334335
ext_actions.append("sleep")
43344336
ext_actions.append("sh_fc")
43354337
ext_actions.append("c_l_s")
@@ -4426,6 +4428,12 @@ def __process_recorded_actions(self):
44264428
sb_actions.append('self.%s("%s")' % (method, action[1]))
44274429
else:
44284430
sb_actions.append("self.%s('%s')" % (method, action[1]))
4431+
elif action[0] == "r_clk":
4432+
method = "context_click"
4433+
if '"' not in action[1]:
4434+
sb_actions.append('self.%s("%s")' % (method, action[1]))
4435+
else:
4436+
sb_actions.append("self.%s('%s')" % (method, action[1]))
44294437
elif action[0] == "canva":
44304438
method = "click_with_offset"
44314439
selector = action[1][0]
@@ -4460,6 +4468,12 @@ def __process_recorded_actions(self):
44604468
sb_actions.append(
44614469
"self.%s('%s', '%s')" % (method, action[1], text)
44624470
)
4471+
elif action[0] == "hover":
4472+
method = "hover"
4473+
if '"' not in action[1]:
4474+
sb_actions.append('self.%s("%s")' % (method, action[1]))
4475+
else:
4476+
sb_actions.append("self.%s('%s')" % (method, action[1]))
44634477
elif action[0] == "e_mfa":
44644478
method = "enter_mfa_code"
44654479
text = action[2].replace("\n", "\\n")
@@ -4830,6 +4844,7 @@ def __process_recorded_actions(self):
48304844
new_file = True
48314845
sb_config._recorded_actions[filename] = []
48324846
data.append("from seleniumbase import BaseCase")
4847+
data.append("BaseCase.main(__name__, __file__)")
48334848
data.append("")
48344849
data.append("")
48354850
data.append("class %s(BaseCase):" % classname)

0 commit comments

Comments
 (0)