Skip to content

Commit 3130a13

Browse files
authored
Merge pull request #1173 from seleniumbase/fix-the-algorithm-for-iframe-detection
Fix the algorithm for detecting if the driver switched to a frame
2 parents 7fda761 + 551e88b commit 3130a13

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "2.3.11"
2+
__version__ = "2.3.12"

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)