@@ -1138,6 +1138,8 @@ def get_locale_code(self):
1138
1138
1139
1139
def go_back(self):
1140
1140
self.__check_scope()
1141
+ if hasattr(self, "recorder_mode") and self.recorder_mode:
1142
+ self.save_recorded_actions()
1141
1143
pre_action_url = self.driver.current_url
1142
1144
self.__last_page_load_url = None
1143
1145
self.driver.back()
@@ -1156,6 +1158,8 @@ def go_back(self):
1156
1158
1157
1159
def go_forward(self):
1158
1160
self.__check_scope()
1161
+ if hasattr(self, "recorder_mode") and self.recorder_mode:
1162
+ self.save_recorded_actions()
1159
1163
self.__last_page_load_url = None
1160
1164
self.driver.forward()
1161
1165
if self.recorder_mode:
@@ -3995,9 +3999,19 @@ def activate_jquery(self):
3995
3999
3996
4000
def activate_demo_mode(self):
3997
4001
self.demo_mode = True
4002
+ if self.recorder_mode:
4003
+ time_stamp = self.execute_script("return Date.now();")
4004
+ origin = self.get_origin()
4005
+ action = ["a_d_m", "", origin, time_stamp]
4006
+ self.__extra_actions.append(action)
3998
4007
3999
4008
def deactivate_demo_mode(self):
4000
4009
self.demo_mode = False
4010
+ if self.recorder_mode:
4011
+ time_stamp = self.execute_script("return Date.now();")
4012
+ origin = self.get_origin()
4013
+ action = ["d_d_m", "", origin, time_stamp]
4014
+ self.__extra_actions.append(action)
4001
4015
4002
4016
def activate_design_mode(self):
4003
4017
# Activate Chrome's Design Mode, which lets you edit a site directly.
@@ -4052,6 +4066,8 @@ def save_recorded_actions(self):
4052
4066
end of the test. This is only needed in special cases because most
4053
4067
actions that result in a new origin, (such as clicking on a link),
4054
4068
should automatically open a new tab while Recorder Mode is enabled."""
4069
+ if self.driver is None:
4070
+ return
4055
4071
url = self.get_current_url()
4056
4072
if url and len(url) > 0:
4057
4073
if ("http:") in url or ("https:") in url or ("file:") in url:
@@ -4087,6 +4103,8 @@ def __get_recorded_actions_on_active_tab(self):
4087
4103
return []
4088
4104
4089
4105
def __process_recorded_actions(self):
4106
+ if self.driver is None:
4107
+ return
4090
4108
import colorama
4091
4109
4092
4110
raw_actions = [] # All raw actions from sessionStorage
@@ -4351,6 +4369,8 @@ def __process_recorded_actions(self):
4351
4369
ext_actions.append("hover")
4352
4370
ext_actions.append("sleep")
4353
4371
ext_actions.append("sh_fc")
4372
+ ext_actions.append("a_d_m")
4373
+ ext_actions.append("d_d_m")
4354
4374
ext_actions.append("c_l_s")
4355
4375
ext_actions.append("c_s_s")
4356
4376
ext_actions.append("d_a_c")
@@ -4813,6 +4833,10 @@ def __process_recorded_actions(self):
4813
4833
sb_actions.append("self.%s()" % method)
4814
4834
elif action[0] == "pr_da":
4815
4835
sb_actions.append("self.process_deferred_asserts()")
4836
+ elif action[0] == "a_d_m":
4837
+ sb_actions.append("self.activate_demo_mode()")
4838
+ elif action[0] == "d_d_m":
4839
+ sb_actions.append("self.deactivate_demo_mode()")
4816
4840
elif action[0] == "c_l_s":
4817
4841
sb_actions.append("self.clear_local_storage()")
4818
4842
elif action[0] == "c_s_s":
@@ -5260,8 +5284,6 @@ def highlight(self, selector, by="css selector", loops=None, scroll=True):
5260
5284
box_end = style.find(";", box_start) + 1
5261
5285
original_box_shadow = style[box_start:box_end]
5262
5286
o_bs = original_box_shadow
5263
-
5264
- orig_selector = selector
5265
5287
if ":contains" not in selector and ":first" not in selector:
5266
5288
selector = re.escape(selector)
5267
5289
selector = self.__escape_quotes_if_needed(selector)
@@ -5281,9 +5303,8 @@ def highlight(self, selector, by="css selector", loops=None, scroll=True):
5281
5303
if self.get_session_storage_item("pause_recorder") == "no":
5282
5304
time_stamp = self.execute_script("return Date.now();")
5283
5305
origin = self.get_origin()
5284
- action = ["hi_li", orig_selector , origin, time_stamp]
5306
+ action = ["hi_li", selector , origin, time_stamp]
5285
5307
self.__extra_actions.append(action)
5286
- time.sleep(0.065)
5287
5308
5288
5309
def press_up_arrow(self, selector="html", times=1, by="css selector"):
5289
5310
"""Simulates pressing the UP Arrow on the keyboard.
@@ -14592,6 +14613,10 @@ def tearDown(self):
14592
14613
return
14593
14614
if hasattr(self, "recorder_mode") and self.recorder_mode:
14594
14615
self.__process_recorded_actions()
14616
+ try:
14617
+ self.remove_session_storage_item("recorded_actions")
14618
+ except Exception:
14619
+ pass
14595
14620
self.__called_teardown = True
14596
14621
self.__called_setup = False
14597
14622
try:
0 commit comments