Skip to content

[🐛 Bug]: After a dynamically loaded iframe is removed from the DOM, SafariDriver cannot interact with the document anymore #15713

Open
@Sshviq

Description

@Sshviq

Description

When using SafariDriver, if you switch into a dynamically loaded iframe (such as a login modal), and that iframe is then removed from the DOM (e.g., after submitting a login form), and there are no more frames present on the page, all subsequent WebDriver commands (findElement, getPageSource, etc.) throw a NoSuchFrameException.
If you attempt to recover by calling driver.switchTo().defaultContent(), subsequent interactions no longer throw, but instead consistently return null for every command (for example, driver.findElement returns null, driver.getPageSource() returns null, and executing JavaScript returns null).

Reproducible Code

driver.get(url)
driver.switchTo().frame(<my_dynamic_frame>);
//Submit the login so that the iframe is removed from the page.
driver.getPageSource();
//Result: org.openqa.selenium.NoSuchFrameException
driver.switchTo().defaultContent();
driver.getPageSource();
//Result: null

Debugging Logs

Driver info: org.openqa.selenium.safari.SafariDriver
Command: [577D814E-8A32-4640-8445-1BE31A30A571, getPageSource {}]
Capabilities {acceptInsecureCerts: false, browserName: Safari, browserVersion: 17.3.1, platformName: MAC, safari:automaticInspection: true, safari:automaticProfiling: false, safari:diagnose: true, safari:platformBuildVersion: 23D60, safari:platformVersion: 14.3.1, safari:useSimulator: false, selenoid:options: {enableVNC: true, enableVideo: false, name:---}, setWindowRect: true, strictFileInteractability: false, webkit:WebRTC: {DisableICECandidateFiltering: false, DisableInsecureMediaCapture: false}}
Session ID: 577D814E-8A32-4640-8445-1BE31A30A571

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!B-gridEverything grid and server relatedC-javaJava BindingsI-defectSomething is not working as intendedOS-mac

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions