Skip to content

Commit 2fadded

Browse files
committed
Fix algorithm for detecting if the driver switched to a frame
1 parent 7fda761 commit 2fadded

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

seleniumbase/fixtures/js_utils.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def is_in_frame(driver):
217217
Returns True if the driver has switched to a frame.
218218
Returns False if the driver was on default content.
219219
"""
220-
return driver.execute_script(
220+
in_basic_frame = driver.execute_script(
221221
"""
222222
var frame = window.frameElement;
223223
if (frame) {
@@ -228,6 +228,13 @@ def is_in_frame(driver):
228228
}
229229
"""
230230
)
231+
location_href = driver.execute_script("""return window.location.href;""")
232+
in_external_frame = False
233+
if driver.current_url != location_href:
234+
in_external_frame = True
235+
if in_basic_frame or in_external_frame:
236+
return True
237+
return False
231238

232239

233240
def safe_execute_script(driver, script):

0 commit comments

Comments
 (0)