Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 Bug]: When we set the capability "webSocketUrl" to true for chromium browsers, the new tab or window opened with anchor tag click, hangs up. #12527

Closed
AMP-BH opened this issue Aug 10, 2023 · 5 comments
Labels
G-chromedriver Requires fixes in ChromeDriver I-defect

Comments

@AMP-BH
Copy link

AMP-BH commented Aug 10, 2023

What happened?

Thank you so much for your time in advance.

So was trying to implement BiDi Log in my project, for which I added the "webSocketUrl" capability as true in driver option.
But since then the anchor links in my code started behaving strangely in chromium browsers. As in when we click on the anchor link, the new tab is getting open, but after that browser gets stuck and does not load the url. Same code works fine
in firefox.

But when I set the "webSocketUrl" capability as false, or remove the same, the code starts working properly.
So I tried the same with simple java selenium code and was able to reproduce the same issue. Hope the sample code helps.

How can we reproduce the issue?

package com.seleniumtest.bugs;

import java.util.*;

import org.openqa.selenium.*;
import org.openqa.selenium.chrome.*;
import org.openqa.selenium.edge.*;
import org.openqa.selenium.firefox.*;

public class WebSocketUrlBug {
  private static final int WAIT_FOR_MILLIS = 2000;
  private static final String URL = "https://www.browserstack.com/";
  static WebDriver driver = null;

  public static void main(String[] args) {
    openNewTabOrWinOnAnchorClick();
  }

  private static void openNewTabOrWinOnAnchorClick() {
    try {
      ChromeOptions options = new ChromeOptions();
//      EdgeOptions options = new EdgeOptions();
//      FirefoxOptions options = new FirefoxOptions();

      options.setCapability("webSocketUrl", true); // <<<<< This causes the issue for Chromium browsers.

      driver = new ChromeDriver(options); // 115.0.5790.171 // Not Working.
//      driver = new EdgeDriver(options); // 115.0.1901.200 // Not Working.
//      driver = new FirefoxDriver(options); // 102.14.0esr // Works fine.

      driver.manage().window().maximize();
      driver.get(URL);

      WebElement ele = driver.findElement(By.partialLinkText("Register now"));
//      ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", ele);
      ele.click();
      Thread.sleep(WAIT_FOR_MILLIS);

      String mainHandle = driver.getWindowHandle();
      Set<String> handles = driver.getWindowHandles();
      System.out.println(handles);

      String newHandle = "";
      for (String handle : handles) {
        if (!handle.equals(mainHandle)) {
          newHandle = handle;
          break;
        }
      }

      driver.switchTo().window(newHandle);
      Thread.sleep(WAIT_FOR_MILLIS);

      driver.switchTo().window(mainHandle);
      Thread.sleep(WAIT_FOR_MILLIS);
    } catch (Exception ex) {
      ex.printStackTrace();
    } finally {
      if (driver != null) {
        driver.quit();
      }
    }
  }

}

Relevant log output

12:56:27 pm: Executing ':WebSocketUrlBug.main()'...

> Task :compileJava
> Task :processResources UP-TO-DATE
> Task :classes

> Task :WebSocketUrlBug.main()
Aug 10, 2023 12:56:33 PM org.openqa.selenium.remote.service.DriverService$Builder getLogOutput
INFO: Driver logs no longer sent to console by default; https://www.selenium.dev/documentation/webdriver/drivers/service/#setting-log-output
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.
Aug 10, 2023 12:56:35 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
WARNING: Unable to find an exact match for CDP version 115, so returning the closest version found: 114

<<<<<<<<<<<<<<<<<<<<<<<<<<< Post browser is closed manually. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

java.lang.NullPointerException: Cannot invoke "java.util.Collection.size()" because "c" is null
	at java.base/java.util.LinkedHashSet.<init>(LinkedHashSet.java:169)
	at org.openqa.selenium.remote.RemoteWebDriver.getWindowHandles(RemoteWebDriver.java:459)
	at com.seleniumtest.bugs.WebSocketUrlBug.openNewTabOrWinOnAnchorClick(WebSocketUrlBug.java:38)
	at com.seleniumtest.bugs.WebSocketUrlBug.main(WebSocketUrlBug.java:14)

BUILD SUCCESSFUL in 34s
3 actionable tasks: 2 executed, 1 up-to-date
12:57:02 pm: Execution finished ':WebSocketUrlBug.main()'.

Operating System

Windows 10

Selenium version

Java 17 with Selenium 4.10, 4.11

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

Chrome 115.0.5790.171, Edge 115.0.1901.200

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

ChromeDriver 115.0.5790.171, EdgeDriver 115.0.1901.200

Are you using Selenium Grid?

NA

@github-actions
Copy link

@AMP-BH, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol
Copy link
Member

diemol commented Aug 10, 2023

If it works in Firefox and not in Chrome you should report it to the Chrome/ChromeDriver folks.

@diemol diemol added G-chromedriver Requires fixes in ChromeDriver and removed needs-triaging labels Aug 10, 2023
@github-actions
Copy link

Hi, @AMP-BH.
This issue has been determined to require fixes in ChromeDriver.

You can see if the feature is passing in the Web Platform Tests.

If it is something new, please create an issue with the ChromeDriver team.
Feel free to comment the issues that you raise back in this issue. Thank you.

@AMP-BH
Copy link
Author

AMP-BH commented Aug 10, 2023

Hello @diemol,

The bug is already raised by someone on ChromeDriver, I found this below link.

https://bugs.chromium.org/p/chromedriver/issues/detail?id=4468&q=webSocketUrl&can=2

EdgeDriver - MicrosoftEdge/EdgeWebDriver#103

Hope chrome driver and edge driver ] team responds.

Copy link

github-actions bot commented Dec 8, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
G-chromedriver Requires fixes in ChromeDriver I-defect
Projects
None yet
Development

No branches or pull requests

2 participants