File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -3939,12 +3939,18 @@ def __are_quotes_escaped(self, string):
3939
3939
def __escape_quotes_if_needed(self, string):
3940
3940
return js_utils.escape_quotes_if_needed(string)
3941
3941
3942
+ def __is_in_frame(self):
3943
+ return js_utils.is_in_frame(self.driver)
3944
+
3942
3945
def bring_active_window_to_front(self):
3943
3946
"""Brings the active browser window to the front.
3944
3947
This is useful when multiple drivers are being used."""
3945
3948
self.__check_scope()
3946
3949
try:
3947
- self.switch_to_window(self.driver.current_window_handle)
3950
+ if not self.__is_in_frame():
3951
+ # Only bring the window to the front if not in a frame
3952
+ # because the driver resets itself to default content.
3953
+ self.switch_to_window(self.driver.current_window_handle)
3948
3954
except Exception:
3949
3955
pass
3950
3956
Original file line number Diff line number Diff line change @@ -212,6 +212,24 @@ def escape_quotes_if_needed(string):
212
212
return string
213
213
214
214
215
+ def is_in_frame (driver ):
216
+ """
217
+ Returns True if the driver has switched to a frame.
218
+ Returns False if the driver was on default content.
219
+ """
220
+ return driver .execute_script (
221
+ """
222
+ var frame = window.frameElement;
223
+ if (frame) {
224
+ return true;
225
+ }
226
+ else {
227
+ return false;
228
+ }
229
+ """
230
+ )
231
+
232
+
215
233
def safe_execute_script (driver , script ):
216
234
"""When executing a script that contains a jQuery command,
217
235
it's important that the jQuery library has been loaded first.
You can’t perform that action at this time.
0 commit comments