Search code examples
seleniumselenium-webdriverwebdriverselenium-chromedriverbrowser-automation

selenium chrome webdriver error: Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session


i hit this error Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. while running the chrome. Any advise please? for full error message is at bottom of my post.

OS: Windows 10 Eclipse: Version: 2020-03 (4.15.0) Build id: 20200313-1211 Chrome: Version 81.0.4044.92 (Official Build) (64-bit) Chrome web driver: Version 81.0.4044.69

import java.net.MalformedURLException;

import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class test {

    public static void main(String[] args) throws TimeoutException{
        // TODO Auto-generated method stub
        System.setProperty("webdriver.chrome.driver", "C:\\Users\\User\\Desktop\\chromedriver.exe");    
        WebDriver driver = new ChromeDriver(); 
         driver.get("https://www.google.com");
        System.out.println(driver.getTitle());
    }
}

Error message output:

Starting ChromeDriver 81.0.4044.69 (6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776}) on port 39285
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{browserName=chrome, chromeOptions=org.openqa.selenium.chrome.ChromeOptions@acf6a1bc, version=, platform=ANY}], required capabilities = Capabilities [{}]
Build info: version: '3.3.1', revision: '5234b325d5', time: '2017-03-10 09:10:29 +0000'
System info: host: 'DESKTOP-TQC1N01', ip: '192.168.0.102', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '13.0.2'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:604)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:244)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:178)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:167)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:156)
    at testscript.test.main(test.java:18)

Solution

  • I have tried below code, If you are using chrome browser version 81.0.4044.92 then downgrade your ChromeDriver to 80.0.3987.106 and give a try. This issue occurs due to compability between your browser and chromedriver. I think you are using selenium grid jar[Unable to create new remote session]. you haave to use Latest stable version 3.141.59

    I have checked same solution and its working fine for me without any issue.

    public class Test {
    
        public static void main(String[] args) {
    
            System.setProperty("webdriver.chrome.driver"," path of chromedriver.exe");
            WebDriver driver = new ChromeDriver();
            driver.get("https://www.google.com");
            System.out.println(driver.getTitle());
        }
    }
    

    enter image description here