Only "bring_active_window_to_front()" if not in a frame
This commit is contained in:
parent
1a4f4ff5fe
commit
c6e87484fa
|
@ -3939,12 +3939,18 @@ class BaseCase(unittest.TestCase):
|
|||
def __escape_quotes_if_needed(self, string):
|
||||
return js_utils.escape_quotes_if_needed(string)
|
||||
|
||||
def __is_in_frame(self):
|
||||
return js_utils.is_in_frame(self.driver)
|
||||
|
||||
def bring_active_window_to_front(self):
|
||||
"""Brings the active browser window to the front.
|
||||
This is useful when multiple drivers are being used."""
|
||||
self.__check_scope()
|
||||
try:
|
||||
self.switch_to_window(self.driver.current_window_handle)
|
||||
if not self.__is_in_frame():
|
||||
# Only bring the window to the front if not in a frame
|
||||
# because the driver resets itself to default content.
|
||||
self.switch_to_window(self.driver.current_window_handle)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
|
|
@ -212,6 +212,24 @@ def escape_quotes_if_needed(string):
|
|||
return string
|
||||
|
||||
|
||||
def is_in_frame(driver):
|
||||
"""
|
||||
Returns True if the driver has switched to a frame.
|
||||
Returns False if the driver was on default content.
|
||||
"""
|
||||
return driver.execute_script(
|
||||
"""
|
||||
var frame = window.frameElement;
|
||||
if (frame) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
def safe_execute_script(driver, script):
|
||||
"""When executing a script that contains a jQuery command,
|
||||
it's important that the jQuery library has been loaded first.
|
||||
|
|
Loading…
Reference in New Issue