How to fix org.openqa.selenium.WebDriverException: newSession

I was using simple code to start the webdriver:

FirefoxOptions option = null;

option = new FirefoxOptions();


System.out.println(“>>>>>>>> before driver”);

driver = new RemoteWebDriver(new URL(“http://localhost:4444/wd/hub") , option);

System.out.println(“>>>>>>> after driver”);

This gave me webdriverexception — newSession.

I got help from selenium irc — thankfully.

Here is how i managed to debug:

First , I was running selenium grid, node as services with systemd with SUDO.
so, i stopped these services.

I then started hub and node without using sudo.

java -jar selenium-server-standalone-3.13.0.jar -role hub

java -Dwebdriver.gecko.driver=”/home/user/geckodriver” -jar selenium-server-standalone-3.13.0.jar -role node -maxSession 10 -browser “browserName=firefox,maxInstances=10” -hub http://localhost:4444/wd/hub maxSession 5 -browser “browserName=firefox,maxInstances=3

I saw better logs without sudo.

in the logs of node I saw this error:

Marionette  TRACE   0 <- [1,1,{"error":"unknown command","message":"newSession","stacktrace":"WebDriverError@chrome://marionette/content/error.js:178: ... et@chrome://marionette/content/server.js:245:8\n_onJSONObjectReady/<@chrome://marionette/content/transport.js:490:9\n"},null]

I googled this and found —

Firefox got automatically updated on my ubuntu server.

So as per this link , i updated geckodriver and got the fix.

To stop firefox from automatically updating , i used —
sudo apt-mark hold firefox

now to run systemctl without sudo
remove USER = ubuntu , add

Programmer and Entrepreneur.