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.

Vladislav
  • 121
  • 1
  • 9
  • Sounds like it's related to this: https://stackoverflow.com/questions/75718422/org-openqa-selenium-remote-http-connectionfailedexception-unable-to-establish-w/75741758#75741758 – pcalkins Mar 16 '23 at 17:31
  • Thank you @pcalkins , your answer was also very helpful to get an understanding of what is the reason of the problem – Vladislav Mar 17 '23 at 09:51

1 Answers1

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:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    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. – Vladislav Mar 17 '23 at 09:05
  • Can it be related to the fact that my Chrome was updated few days ago – Vladislav Mar 17 '23 at 10:40
  • @Vladislav Ofcoarse, all these issues are related to the recent changes pushed in Chrome v111.x – undetected Selenium Mar 17 '23 at 20:06
  • 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? – Vladislav Apr 19 '23 at 09:29
  • hello again. I am sorry to disturb, but may be you have any other suggestions why the issue is back after one month ? – Vladislav Apr 19 '23 at 09:35