@@ -111,6 +111,9 @@ def __initialize_variables(self):
111
111
self.__extra_actions = []
112
112
self.__js_start_time = 0
113
113
self.__set_c_from_switch = False
114
+ self.__frame_switch_layer = 0 # Used by Recorder-Mode
115
+ self.__frame_switch_multi = False # Used by Recorder-Mode
116
+ self.__last_saved_url = None # Used by Recorder-Mode
114
117
self.__called_setup = False
115
118
self.__called_teardown = False
116
119
self.__start_time_ms = None
@@ -3002,9 +3005,21 @@ def frame_switch(self, frame, timeout=None):
3002
3005
# Perform actions here that should be done within the iframe.
3003
3006
# The iframe is automatically exited after the "with" block ends.
3004
3007
"""
3008
+ if self.recorder_mode:
3009
+ self.__frame_switch_layer += 1
3010
+ if self.__frame_switch_layer >= 2:
3011
+ self.__frame_switch_multi = True
3005
3012
self.switch_to_frame(frame, timeout=timeout)
3006
3013
yield
3007
3014
self.switch_to_parent_frame()
3015
+ if self.recorder_mode:
3016
+ self.__frame_switch_layer -= 1
3017
+ if self.__frame_switch_layer < 0:
3018
+ self.__frame_switch_layer = 0
3019
+ self.__frame_switch_multi = False
3020
+ if self.__frame_switch_layer == 0 and self.__frame_switch_multi:
3021
+ self.refresh()
3022
+ self.__frame_switch_multi = False
3008
3023
3009
3024
def set_content_to_frame(self, frame, timeout=None):
3010
3025
"""Replaces the page html with an iframe's html from that page.
@@ -12337,11 +12352,22 @@ def __ad_block_as_needed(self):
12337
12352
self.__last_page_load_url = current_url
12338
12353
12339
12354
def __disable_beforeunload_as_needed(self):
12355
+ """Disables beforeunload as needed. Also resets frame_switch state."""
12340
12356
if (
12341
12357
hasattr(self, "_disable_beforeunload")
12342
12358
and self._disable_beforeunload
12343
12359
):
12344
12360
self.disable_beforeunload()
12361
+ if self.recorder_mode:
12362
+ try:
12363
+ current_url = self.get_current_url
12364
+ except Exception:
12365
+ current_url = None
12366
+ self.__last_saved_url = None
12367
+ if current_url != self.__last_saved_url:
12368
+ self.__frame_switch_layer = 0
12369
+ self.__frame_switch_multi = False
12370
+ self.__last_saved_url = current_url
12345
12371
12346
12372
############
12347
12373
0 commit comments