简体   繁体   中英

SessionNotCreatedException: Could not start a new session. Response code 500 error using Selenium Java and WebDriverManager through pom.xml

I want to test my script on chrome beta version and for that reason I have installed chrome beta version but somehow I am not able to start it using Selenium Java. I have all the needed dependency added in pom.xml file regarding webdriver manager etc. I am sharing my console error and also script.

ChromeOptions optionsBeta = new ChromeOptions();
optionsBeta.setBinary("C:\\Users\\WRP\\Downloads\\Programs\\ChromeSetup.exe");
System.setProperty("webdriver.chrome.driver", "C:\\Users\\WRP\\eclipse-workspace\\PracticeProject\\Driver\\chromedriver.exe");
WebDriver driver = new ChromeDriver(optionsBeta);
//System.setProperty("webdriver.chrome.driver", "./Driver/chromedriver.exe");
//  WebDriver driver = new ChromeDriver();
WebDriverManager.chromedriver().setup();
//WebDriverManager.chromedriver().driverVersion("104.0.5112.29").setup();
//WebDriver driver = new ChromeDriver();
WebDriverWait waits=new WebDriverWait (driver, Duration.ofSeconds(10));

Error tracelogs:

Starting ChromeDriver 104.0.5112.29 (eff877e18f767c77fef0481a1cba402c8cbad404-refs/branch-heads/5112@{#422}) on port 55215
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location C:\Users\WRP\Downloads\Programs\ChromeSetup.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '4.3.0', revision: 'a4995e2c09*'
System info: host: 'AWAIS-PC', ip: '192.168.1.62', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '18.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [], binary: C:\Users\WRP\Downloads\Prog..., extensions: []}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [], binary: C:\Users\WRP\Downloads\Prog..., extensions: []}}}]
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:144)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:102)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:264)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:179)
    at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:101)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:81)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:70)
    at First_Test.Practice_First.main(Practice_First.java:29)

This error message...

Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location C:\Users\WRP\Downloads\Programs\ChromeSetup.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)

...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context ie session.

Your have to take care of a couple of things here as follows:

  • setBinary() argument should be used to point to the binary executable ie chrome.exe post installation of the browser software ( ChromeSetup.exe )

     optionsBeta.setBinary("C:\\location\\to\\chrome.exe");
  • You'd use either of the following ( not both ):

    • The downloaded version of the chromedriver.exe using the System.setProperty() line as follows:

       System.setProperty("webdriver.chrome.driver", "C:\\Users\\WRP\\eclipse-workspace\\PracticeProject\\Driver\\chromedriver.exe");
    • The WebDriverManager dependency in pom.xml and setup the chromedriver as:

       WebDriverManager.chromedriver().setup();

Your effective code block will be:

  • Using downloaded ChromeDriver :

     System.setProperty("webdriver.chrome.driver", "C:\\Users\\WRP\\eclipse-workspace\\PracticeProject\\Driver\\chromedriver.exe"); ChromeOptions optionsBeta = new ChromeOptions(); optionsBeta.setBinary("C:\\location\\to\\chrome.exe"); WebDriver driver = new ChromeDriver(optionsBeta);
  • Using Maven Dependency in pom.xml :

     WebDriverManager.chromedriver().driverVersion("104.0.5112.29").setup(); ChromeOptions optionsBeta = new ChromeOptions(); optionsBeta.setBinary("C:\\location\\to\\chrome.exe"); WebDriver driver = new ChromeDriver(optionsBeta);

Use the below chrome option

options = webdriver.ChromeOptions()
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--ignore-ssl-errors=yes')
options.add_argument('--ignore-certificate-errors')

This line very important on skip this error

options.add_argument('--disable-dev-shm-usage')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question org.openqa.selenium.SessionNotCreatedException: Message: Could not start a new session. Response code 500 error using Selenium Java org.openqa.selenium.SessionNotCreatedException: Message: Could not start a new session. Response code 500 error using Appium Java Could not start a new session. Response code 500. Message: unknown error: DevToolsActivePort file doesn't exist error using Selenium ChromeDriver Java Selenium - Could not start a new session. Response code 500. Message: unknown error: cannot create temp dir for unpacking extensions Selenium: Could not start a new session. Response code 500. Message: session not created: This version of ChomeDriver only supports Chrome version 102 org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Error while creating session with the driver service-docker container org.openqa.selenium.SessionNotCreatedException:Could not start a new session.Response code 500.Message:unknown error: Failed to create Chrome process Could not start a new session. Response code 500. Message: unknown error: Microsoft Edge failed to start: crashed Failed to load class "org.slf4j.impl.StaticLoggerBinder" and SessionNotCreatedException: Could not start a new session using Selenium Java with Maven org.openqa.selenium.SessionNotCreatedException: Unable to create session error using GeckoDriver and Firefox through Selenium and Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM