EdgeWebDriver icon indicating copy to clipboard operation
EdgeWebDriver copied to clipboard

Problem opening new tab in inprivate mode for edge.

Open AMP-BH opened this issue 2 years ago • 5 comments

Ref - https://github.com/SeleniumHQ/selenium/issues/11729

What happened?

Problem opening new tab(s) in InPrivate mode for edge.

How can we reproduce the issue?

package com.seleniumtest.bugs;

import io.github.bonigarcia.wdm.WebDriverManager;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WindowType;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;

public class NewTabBug {
  static WebDriver driver = null;
  public static void main(String[] args) {
    newTabEd();
    newTabCh();
  }

  private static void newTabEd() {
    try {
      WebDriverManager.edgedriver().setup();

      EdgeOptions edgeOptions = new EdgeOptions();
      edgeOptions.addArguments("--inprivate");

      driver = new EdgeDriver(edgeOptions);
      driver.manage().window().maximize();
      driver.get("https://google.com");

      driver.switchTo().newWindow(WindowType.TAB);
      driver.get("https://google.com");

      driver.switchTo().newWindow(WindowType.WINDOW);
      driver.get("https://google.com");
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      if (driver != null) {
        driver.quit();
      }
    }
  }

  private static void newTabCh() {
    try {
      WebDriverManager.chromedriver().setup();

      ChromeOptions chromeOptions = new ChromeOptions();
      chromeOptions.addArguments("--incognito");

      WebDriverManager.chromedriver().setup();
      driver = new ChromeDriver(chromeOptions);
      driver.manage().window().maximize();
      driver.get("https://google.com");

      driver.switchTo().newWindow(WindowType.TAB);
      driver.get("https://google.com");

      driver.switchTo().newWindow(WindowType.WINDOW);
      driver.get("https://google.com");
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      if (driver != null) {
        driver.quit();
      }
    }
  }
}

Relevant log output

01:57:29 pm: Executing ':NewTabBug.main()'...

> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes

> Task :NewTabBug.main()
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
Starting Microsoft Edge WebDriver 110.0.1587.57 (01109f62642156c7eedb96d3c6fce911f01a896c) on port 35076
To submit feedback, report a bug, or suggest new features, please visit https://github.com/MicrosoftEdge/EdgeWebDriver

Only local connections are allowed.
Please see https://aka.ms/WebDriverSecurity for suggestions on keeping Microsoft Edge WebDriver safe.

Microsoft Edge WebDriver was started successfully.
[1677832053.549][WARNING]: virtual void DevToolsClientImpl::AddListener(DevToolsEventListener *) subscribing a listener to the already connected DevToolsClient. Connection notification will not arrive.
Mar 03, 2023 1:57:33 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 110, so returning the closest version found: 109
org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Failed to open new tab - no browser is open"}
  (Session info: MicrosoftEdge=110.0.1587.57)
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1'
Driver info: org.openqa.selenium.edge.EdgeDriver
Command: [0dcb141d00c30a1fbb1640f4c2ecc623, newWindow {type=tab}]
Capabilities {acceptInsecureCerts: false, browserName: msedge, browserVersion: 110.0.1587.57, ms:edgeOptions: {debuggerAddress: localhost:64148}, msedge: {msedgedriverVersion: 110.0.1587.57 (01109f626421..., userDataDir: C:\Users\pateami\AppData\Lo...}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: WINDOWS, proxy: Proxy(), se:cdp: ws://localhost:64148/devtoo..., se:cdpVersion: 110.0.1587.57, 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: 0dcb141d00c30a1fbb1640f4c2ecc623
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
	at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.newWindow(RemoteWebDriver.java:1056)
	at com.seleniumtest.bugs.NewTabBug.newTabEd(NewTabBug.java:30)
	at com.seleniumtest.bugs.NewTabBug.main(NewTabBug.java:15)
Starting ChromeDriver 110.0.5481.77 (65ed616c6e8ee3fe0ad64fe83796c020644d42af-refs/branch-heads/5481@{#839}) on port 8546
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1677832064.204][WARNING]: virtual void DevToolsClientImpl::AddListener(DevToolsEventListener *) subscribing a listener to the already connected DevToolsClient. Connection notification will not arrive.
Mar 03, 2023 1:57:44 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 110, so returning the closest version found: 109
org.openqa.selenium.WebDriverException: unknown error: unhandled inspector error: {"code":-32000,"message":"Failed to open new tab - no browser is open"}
  (Session info: chrome=110.0.5481.178)
Build info: version: '4.8.0', revision: '267030adea'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [4b3133796e9984fd60b240f20a151bc7, newWindow {type=tab}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 110.0.5481.178, chrome: {chromedriverVersion: 110.0.5481.77 (65ed616c6e8e..., userDataDir: C:\Users\pateami\AppData\Lo...}, goog:chromeOptions: {debuggerAddress: localhost:54190}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: WINDOWS, proxy: Proxy(), se:cdp: ws://localhost:54190/devtoo..., se:cdpVersion: 110.0.5481.178, 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: 4b3133796e9984fd60b240f20a151bc7
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
	at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
	at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:543)
	at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.newWindow(RemoteWebDriver.java:1056)
	at com.seleniumtest.bugs.NewTabBug.newTabCh(NewTabBug.java:56)
	at com.seleniumtest.bugs.NewTabBug.main(NewTabBug.java:16)

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4/userguide/command_line_interface.html#sec:command_line_warnings

BUILD SUCCESSFUL in 24s
2 actionable tasks: 2 executed
01:57:54 pm: Execution finished ':NewTabBug.main()'.

Operating System

Windows 10

Selenium version

Selenium 4.8, Java 17.0.1

What are the browser(s) and version(s) where you see this issue?

Chrome 110.0.5481.178, Edge 110.0.1587.57

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 110.0.5481.77, Microsoft Edge WebDriver 110.0.1587.57

Are you using Selenium Grid?

No

AMP-BH avatar Mar 09 '23 03:03 AMP-BH

Hi @AMP-BH. I've added this to our internal backlog for investigation.

bwalderman avatar Mar 17 '23 22:03 bwalderman

Hi, This issue still unfixed in Selenium 4.12.4 with Edge 116.0.1938.76 driver.SwitchTo().NewWindow(WindowType.Tab); with normal mode, works fine but with [InPrivate mode] only it gets the mentioned error above: Error message: unknown error: unhandled inspector error: {"code":-32000,"message":"Failed to open new tab - no browser is open"} (Session info: MicrosoftEdge=116.0.1938.76) is there a way to workaround?

ShoodEver avatar Sep 10 '23 16:09 ShoodEver

I have the same problem. Is there any temporary solution?

MemoryShadow avatar Sep 27 '23 12:09 MemoryShadow

workaround by this code, it does the same: IJavaScriptExecutor js = (IJavaScriptExecutor)driver; js.ExecuteScript("window.open('', '_blank')"); driver.SwitchTo().Window(driver.WindowHandles.Last);

ShoodEver avatar Sep 27 '23 15:09 ShoodEver

workaround by this code, it does the same:解决方法 通过此代码,它执行相同的操作: IJavaScriptExecutor js = (IJavaScriptExecutor)driver; js.ExecuteScript("window.open('', '_blank')"); driver.SwitchTo().Window(driver.WindowHandles.Last);

Thanks for your reply, I am developing in Python, on my side, WindowHandles is a list rather than an object, and may not be able to use this scheme

MemoryShadow avatar Sep 28 '23 01:09 MemoryShadow