What happened?
TracedCommandExecutor throws NPE for driver.switchTo().defaultContent() method for RemoteWebDriver
Caused by: java.lang.NullPointerException
at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:47)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:559)
It fails here because
driver.switchTo().defaultContent() calls DriverCommand.SWITCH_TO_FRAME(null) and command parameter null. It causes NPE on parameter.getValue().toString()

How can we reproduce the issue?
@Test
public void foo() throws MalformedURLException {
// You have to setup some Selenium grid to use RemoteWebDriver
ChromeOptions chromeOptions = new ChromeOptions();
RemoteWebDriver driver = null;
try {
driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), chromeOptions);
driver.get("https://www.w3schools.com/html/html_iframe.asp");
driver.switchTo().frame(0);
driver.switchTo().defaultContent();
} catch (Throwable e) {
throw e;
} finally {
if (driver != null) {
driver.quit();
}
}
}
Relevant log output
System info: host: 'bo-MS-7B86', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.11.0-40-generic', java.version: '1.8.0_302'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [6adcb1735cb29eb0dccefcc24f1dd320, switchToFrame {id=null}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 96.0.4664.45, chrome: ..., javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: 6adcb1735cb29eb0dccefcc24f1dd320
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:583)
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.defaultContent(RemoteWebDriver.java:1042)
at com.example.demo_selenied.MainPageTest.iframeTest2(MainPageTest.java:106)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
...
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:47)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:559)
...
Operating System
Any
Selenium version
4.1.0
What are the browser(s) and version(s) where you see this issue?
Any remote
What are the browser driver(s) and version(s) where you see this issue?
Any
Are you using Selenium Grid?
Selenoid
What happened?
TracedCommandExecutor throws NPE for
driver.switchTo().defaultContent()method for RemoteWebDriverIt fails here because
driver.switchTo().defaultContent()callsDriverCommand.SWITCH_TO_FRAME(null)and command parameternull. It causes NPE onparameter.getValue().toString()How can we reproduce the issue?
@Test public void foo() throws MalformedURLException { // You have to setup some Selenium grid to use RemoteWebDriver ChromeOptions chromeOptions = new ChromeOptions(); RemoteWebDriver driver = null; try { driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), chromeOptions); driver.get("https://www.w3schools.com/html/html_iframe.asp"); driver.switchTo().frame(0); driver.switchTo().defaultContent(); } catch (Throwable e) { throw e; } finally { if (driver != null) { driver.quit(); } } }Relevant log output
Operating System
Any
Selenium version
4.1.0
What are the browser(s) and version(s) where you see this issue?
Any remote
What are the browser driver(s) and version(s) where you see this issue?
Any
Are you using Selenium Grid?
Selenoid