{"code":-32000,"message":"Browser window not found"} when maximizing edge window via RemoteWebDriver in selenium grid
Hi!
When I run follwing code against my selenium hub:
import java.net.URI;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class WindowsMaximizeTest {
@Test
public void testSelenium() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.addArguments("--headless");
capabilities.setCapability(EdgeOptions.CAPABILITY, edgeOptions);
WebDriver driver = new RemoteWebDriver(URI.create("<my grid url>").toURL(), capabilities);
driver.manage().window().maximize();
driver.get("http://www.google.com");
driver.quit();
}
}
I get following error:
org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Browser window not found"}
(Session info: MicrosoftEdge=132.0.2957.115)
Build info: version: '4.13.0', revision: 'ba948ece5b*'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_431'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [1ac9d96d43084c83f03f5fda8910f4b9, maximizeCurrentWindow {}]
Capabilities {acceptInsecureCerts: false, browserName: MicrosoftEdge, browserVersion: 132.0.2957.115, fedcm:accounts: true, ms:edgeOptions: {debuggerAddress: localhost:58446}, msedge: {msedgedriverVersion: 132.0.2957.115 (f14150e8a7c..., userDataDir: C:\WINDOWS\SystemTemp\scope...}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: Windows 10, proxy: Proxy(), se:bidiEnabled: false, se:cdp: ws://10.47.170.93:4444/sess..., se:cdpVersion: 132.0.2957.115, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
Session ID: 1ac9d96d43084c83f03f5fda8910f4b9
java.lang.reflect.Constructor.newInstance(Constructor.java:423)
org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:52)
org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:191)
org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:602)
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:675)
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:679)
org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteWindow.maximize(RemoteWebDriver.java:1063)
de.ikb.adf.basis.test.WindowsMaximizeTest.testSelenium(WindowsMaximizeTest.java:27)
When removing "driver.manage().window().maximize();", then the test starts. But some of my tests needs maximized browser, as they cannot set focus on items outside the visible browser window. By the way same error occurs with driver.manage().window().setSize.
Best regards Torsten
You wouldn't need invoke either maximize or setSize if edge driver was able to launch edge browser with shortcut (.lnk file). In that case it would be possible to add --start-maximized command line switch to the command line. (As of now unfortunately only msedge.exe is searched for in several folders.)
Here you can see the possible command line switches: https://peter.sh/experiments/chromium-command-line-switches/
But as far as I know I cannot call the edge browser with shortcut and especially not via selenium grid!?
That is true and that's why I raised a feature request to modify edge driver to do that. See: https://github.com/MicrosoftEdge/EdgeWebDriver/issues/141
It is possible to show how edge driver searches msedge.exe with setting EdreDriverService.UseVerboseLogging property to true.
I have the same problem when I try to open a browser with the optional auto-open-devtools-for-tabs flag (using Selenium Grid). Does anyone know how to fix this? It was working correctly in version 136 of Chrome. Thanks in advance