Skip to content

Commit d6cb386

Browse files
committed
Update Recorder Mode
1 parent e179dc3 commit d6cb386

File tree

2 files changed

+58
-4
lines changed

2 files changed

+58
-4
lines changed

seleniumbase/behave/behave_helper.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ def generate_gherkin(srt_actions):
231231
sb_actions.append('%s "%s"' % (method, action[1]))
232232
else:
233233
sb_actions.append("%s '%s'" % (method, action[1]))
234+
elif action[0] == "acc_a":
235+
sb_actions.append("Accept alert")
236+
elif action[0] == "dis_a":
237+
sb_actions.append("Dismiss alert")
234238
elif action[0] == "hi_li":
235239
method = "Highlight"
236240
if '"' not in action[1]:

seleniumbase/fixtures/base_case.py

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4296,6 +4296,10 @@ def __process_recorded_actions(self):
42964296
and srt_actions[n - 1][0] == "sh_fc"
42974297
):
42984298
srt_actions[n - 1][0] = "_skip"
4299+
for n in range(len(srt_actions)):
4300+
if srt_actions[n][0] == "canva":
4301+
srt_actions[n][1][1] = math.ceil(float(srt_actions[n][1][1]))
4302+
srt_actions[n][1][2] = math.ceil(float(srt_actions[n][1][2]))
42994303
ext_actions = []
43004304
ext_actions.append("_url_")
43014305
ext_actions.append("js_cl")
@@ -4305,6 +4309,8 @@ def __process_recorded_actions(self):
43054309
ext_actions.append("as_el")
43064310
ext_actions.append("as_ep")
43074311
ext_actions.append("asenv")
4312+
ext_actions.append("acc_a")
4313+
ext_actions.append("dis_a")
43084314
ext_actions.append("hi_li")
43094315
ext_actions.append("as_lt")
43104316
ext_actions.append("as_ti")
@@ -4635,6 +4641,10 @@ def __process_recorded_actions(self):
46354641
sb_actions.append('self.%s("%s")' % (method, action[1]))
46364642
else:
46374643
sb_actions.append("self.%s('%s')" % (method, action[1]))
4644+
elif action[0] == "acc_a":
4645+
sb_actions.append("self.accept_alert()")
4646+
elif action[0] == "dis_a":
4647+
sb_actions.append("self.dismiss_alert()")
46384648
elif action[0] == "hi_li":
46394649
method = "highlight"
46404650
if '"' not in action[1]:
@@ -8860,15 +8870,35 @@ def wait_for_and_accept_alert(self, timeout=None):
88608870
timeout = settings.LARGE_TIMEOUT
88618871
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
88628872
timeout = self.__get_new_timeout(timeout)
8863-
return page_actions.wait_for_and_accept_alert(self.driver, timeout)
8873+
alert = page_actions.wait_for_and_accept_alert(self.driver, timeout)
8874+
if self.recorder_mode:
8875+
url = self.get_current_url()
8876+
if url and len(url) > 0:
8877+
if ("http:") in url or ("https:") in url or ("file:") in url:
8878+
if self.get_session_storage_item("pause_recorder") == "no":
8879+
time_stamp = self.execute_script("return Date.now();")
8880+
origin = self.get_origin()
8881+
action = ["acc_a", "", origin, time_stamp]
8882+
self.__extra_actions.append(action)
8883+
return alert
88648884

88658885
def wait_for_and_dismiss_alert(self, timeout=None):
88668886
self.__check_scope()
88678887
if not timeout:
88688888
timeout = settings.LARGE_TIMEOUT
88698889
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
88708890
timeout = self.__get_new_timeout(timeout)
8871-
return page_actions.wait_for_and_dismiss_alert(self.driver, timeout)
8891+
alert = page_actions.wait_for_and_dismiss_alert(self.driver, timeout)
8892+
if self.recorder_mode:
8893+
url = self.get_current_url()
8894+
if url and len(url) > 0:
8895+
if ("http:") in url or ("https:") in url or ("file:") in url:
8896+
if self.get_session_storage_item("pause_recorder") == "no":
8897+
time_stamp = self.execute_script("return Date.now();")
8898+
origin = self.get_origin()
8899+
action = ["dis_a", "", origin, time_stamp]
8900+
self.__extra_actions.append(action)
8901+
return alert
88728902

88738903
def wait_for_and_switch_to_alert(self, timeout=None):
88748904
self.__check_scope()
@@ -8887,7 +8917,17 @@ def accept_alert(self, timeout=None):
88878917
timeout = settings.SMALL_TIMEOUT
88888918
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
88898919
timeout = self.__get_new_timeout(timeout)
8890-
return page_actions.wait_for_and_accept_alert(self.driver, timeout)
8920+
alert = page_actions.wait_for_and_accept_alert(self.driver, timeout)
8921+
if self.recorder_mode:
8922+
url = self.get_current_url()
8923+
if url and len(url) > 0:
8924+
if ("http:") in url or ("https:") in url or ("file:") in url:
8925+
if self.get_session_storage_item("pause_recorder") == "no":
8926+
time_stamp = self.execute_script("return Date.now();")
8927+
origin = self.get_origin()
8928+
action = ["acc_a", "", origin, time_stamp]
8929+
self.__extra_actions.append(action)
8930+
return alert
88918931

88928932
def dismiss_alert(self, timeout=None):
88938933
"""Same as wait_for_and_dismiss_alert(), but smaller default T_O"""
@@ -8896,7 +8936,17 @@ def dismiss_alert(self, timeout=None):
88968936
timeout = settings.SMALL_TIMEOUT
88978937
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
88988938
timeout = self.__get_new_timeout(timeout)
8899-
return page_actions.wait_for_and_dismiss_alert(self.driver, timeout)
8939+
alert = page_actions.wait_for_and_dismiss_alert(self.driver, timeout)
8940+
if self.recorder_mode:
8941+
url = self.get_current_url()
8942+
if url and len(url) > 0:
8943+
if ("http:") in url or ("https:") in url or ("file:") in url:
8944+
if self.get_session_storage_item("pause_recorder") == "no":
8945+
time_stamp = self.execute_script("return Date.now();")
8946+
origin = self.get_origin()
8947+
action = ["dis_a", "", origin, time_stamp]
8948+
self.__extra_actions.append(action)
8949+
return alert
89008950

89018951
def switch_to_alert(self, timeout=None):
89028952
"""Same as wait_for_and_switch_to_alert(), but smaller default T_O"""

0 commit comments

Comments
 (0)