1

I am relatively new for Selenium.

My test automation project would be running without any issues yet at 13th. of March (3 days ago)

I did not change anything on the project itself.

However, starting from 14th. of March when I try to run the project:

enter image description here

I am getting the error:

Failure: 1 : Script desription
java.lang.NullPointerException: Cannot invoke "org.asynchttpclient.ws.WebSocket.sendCloseFrame(int, String)" because "this.socket" is null
java.lang.NullPointerException: Cannot invoke "org.asynchttpclient.ws.WebSocket.sendCloseFrame(int, String)" because "this.socket" is null
    at org.openqa.selenium.remote.http.netty.NettyWebSocket.close(NettyWebSocket.java:116)
    at org.openqa.selenium.devtools.Connection.close(Connection.java:127)
    at java.base/java.util.Optional.ifPresent(Optional.java:178)
    at org.openqa.selenium.chromium.ChromiumDriver.quit(ChromiumDriver.java:192)
    at com.scriptDescription.StepDefinition.Step_DoSomething.before(Step_DoSomething.java:27)
Tests = 29
 : Successes = 28
 : Failures = 1

also see the screenshot: enter image description here The test script would not even start to execute.

the run would be stopped immediately: enter image description here

The web browser is coming up but nothing is happening: enter image description here

Can somebody share any ideas or any help, please.

2
  • Sounds like it's related to this: stackoverflow.com/questions/75718422/… Commented Mar 16, 2023 at 17:31
  • Thank you @pcalkins , your answer was also very helpful to get an understanding of what is the reason of the problem Commented Mar 17, 2023 at 9:51

1 Answer 1

1

This error message...

java.lang.NullPointerException: Cannot invoke "org.asynchttpclient.ws.WebSocket.sendCloseFrame(int, String)" because "this.socket" is null
    at org.openqa.selenium.remote.http.netty.NettyWebSocket.close(NettyWebSocket.java:116)

...implies that there was an issue with the asynchttpclient.


Details

The core issue is Origin header is always sent from WebSocket client with Netty v4.x which is still being used by Selenium. This issue is addressed in Netty v5.x.


Solution

The best solution would be to upgrade to HTTP Client with Selenium 4.5.0 and beyond

However, a quick fix would be to add the argument --remote-allow-origins=* as follows:

ChromeOptions options = new ChromeOptions();
options.addArguments("--remote-allow-origins=*");
WebDriver driver = new ChromeDriver(options);

References

You can find a couple of relevant detailed discussions in:

Sign up to request clarification or add additional context in comments.

5 Comments

Thank You, @undetected Selenium !!! I added this line: "options.addArguments("--remote-allow-origins=*");" exactly as per your advice (lines: ChromeOptions options = new ChromeOptions(); and WebDriver driver = new ChromeDriver(options); are already there) and Voilà everything is working again.
Can it be related to the fact that my Chrome was updated few days ago
@Vladislav Ofcoarse, all these issues are related to the recent changes pushed in Chrome v111.x
Hi Team, now a month since I solved the issue, but it happened again today. It is absolutely identical to how it was before same error. All the changes recommended by @undetected Selenium are at place. Can you give me any suggestions, please?
hello again. I am sorry to disturb, but may be you have any other suggestions why the issue is back after one month ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.