Skip to content

Commit 4fac090

Browse files
committed
Improve the export abilities of The Recorder
1 parent e35e85c commit 4fac090

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3046,7 +3046,10 @@ def __process_recorded_actions(self):
30463046
if (
30473047
(srt_actions[n][0] == "begin" or srt_actions[n][0] == "_url_")
30483048
and n > 0
3049-
and srt_actions[n-1][0] == "click"
3049+
and (
3050+
srt_actions[n-1][0] == "click"
3051+
or srt_actions[n-1][0] == "js_cl"
3052+
)
30503053
):
30513054
url1 = srt_actions[n-1][2]
30523055
if url1.endswith("/"):
@@ -3079,11 +3082,15 @@ def __process_recorded_actions(self):
30793082
and n > 0
30803083
and (
30813084
srt_actions[n-1][0] == "click"
3085+
or srt_actions[n-1][0] == "js_cl"
30823086
or srt_actions[n-1][0] == "input"
30833087
)
30843088
and (int(srt_actions[n][3]) - int(srt_actions[n-1][3]) < 6500)
30853089
):
3086-
if srt_actions[n-1][0] == "click":
3090+
if (
3091+
srt_actions[n-1][0] == "click"
3092+
or srt_actions[n-1][0] == "js_cl"
3093+
):
30873094
if (
30883095
srt_actions[n-1][1].startswith("input")
30893096
or srt_actions[n-1][1].startswith("button")
@@ -3105,6 +3112,12 @@ def __process_recorded_actions(self):
31053112
sb_actions.append('self.%s("%s")' % (method, action[1]))
31063113
else:
31073114
sb_actions.append("self.%s('%s')" % (method, action[1]))
3115+
elif action[0] == "js_cl":
3116+
method = "js_click"
3117+
if '"' not in action[1]:
3118+
sb_actions.append('self.%s("%s")' % (method, action[1]))
3119+
else:
3120+
sb_actions.append("self.%s('%s')" % (method, action[1]))
31083121
elif action[0] == "input":
31093122
method = "type"
31103123
text = action[2].replace("\n", "\\n")
@@ -3679,6 +3692,23 @@ def js_click(
36793692
css_selector = self.convert_to_css_selector(selector, by=by)
36803693
css_selector = re.escape(css_selector) # Add "\\" to special chars
36813694
css_selector = self.__escape_quotes_if_needed(css_selector)
3695+
action = None
3696+
pre_action_url = self.driver.current_url
3697+
pre_window_count = len(self.driver.window_handles)
3698+
if self.recorder_mode:
3699+
time_stamp = self.execute_script("return Date.now();")
3700+
tag_name = None
3701+
href = ""
3702+
if ":contains\\(" not in css_selector:
3703+
tag_name = self.execute_script(
3704+
"return document.querySelector('%s').tagName.toLowerCase()"
3705+
% css_selector
3706+
)
3707+
if tag_name == "a":
3708+
href = self.execute_script(
3709+
"return document.querySelector('%s').href" % css_selector
3710+
)
3711+
action = ["js_cl", selector, href, time_stamp]
36823712
if not all_matches:
36833713
if ":contains\\(" not in css_selector:
36843714
self.__js_click(selector, by=by)

0 commit comments

Comments
 (0)