1

I'm currently trying to write a script for Ghost Browser (Chromium based browser).

ChromeOptions options = new ChromeOptions();
    options.setBinary("C:\\Users\\Admin\\AppData\\Local\\GhostBrowser\\Application\\ghost.exe");
    ChromeDriver driver = new ChromeDriver(options);
    
    driver.get("https://www.google.com");
    

I set the binary path of ChromeDriver to the path of Ghost Browser.

When I execute it, it executes but instantly closes, and gives the following error. I don't know how to handle it, or what arguments to set in order to make it work, please help.

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 51746
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: Could not start a new session. session not created: Chrome version must be between 71 and 75
  (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.19043 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 1.09 seconds
Build info: version: '4.1.0', revision: '87802e897b'
System info: host: 'ADMIN-PC', ip: '10.6.0.129', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [], binary: C:\Users\Admin\AppData\Loca..., extensions: []}}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [], binary: C:\Users\Admin\AppData\Loca..., extensions: []}}}]
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:217)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:169)
    at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$errorHandler$0(JsonWireProtocolResponse.java:54)
    at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
    at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$1(ProtocolHandshake.java:133)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:1002)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:135)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:84)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:62)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:164)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:139)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:559)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:246)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:168)
    at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:108)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:104)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:91)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:80)
    at extras.testclass.main(testclass.java:16)

1 Answers1

0

This error message...

Starting ChromeDriver 2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1) on port 51746

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

Your main issue is the incompatibility between the version of the binaries you are using as:

  • You are using chromedriver=2.46 which is quite old and ancient.

Solution

Ensure that:


Update

You need to download the latest ChromeDriver e.g. ChromeDriver v98.0.4758.102 and store it in your system. Next you have to mention the absolute path of the chromedriver executable through System.setProperty() line as follows:

System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.setBinary("C:\\Users\\Admin\\AppData\\Local\\GhostBrowser\\Application\\ghost.exe");
ChromeDriver driver = new ChromeDriver(options);
driver.get("https://www.google.com");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • Thanks, I downloaded the most recent version of selenium and chromedriver and installed them. I also updated the enviorment variables. But somehow, it gives the same error. Selenium starts Chromedriver 2.46, even though I deleted the older version. It is possible that I still have this version installed somewhere, but as I changed the enviorment variables I'm not sure why it is still being executed. How can I tell selenium to execute v98.0 ? – stackedgorilla Feb 20 '22 at 15:47
  • @stackedgorilla Checkout the updated answer and let me know the status. – undetected Selenium Feb 20 '22 at 16:19
  • I updated and matched both to v.98, now i get the following (seperated in mulitiple comments) : – stackedgorilla Feb 22 '22 at 22:26
  • ``` SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Starting ChromeDriver 98.0.4758.102 (273bf7ac8c909cde36982d27f66f3c70846a3718-refs/branch-heads/4758@{#1151}) on port 49851 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. ``` – stackedgorilla Feb 22 '22 at 22:27
  • Feb. 22, 2022 11:20:35 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFORMATION: Detected dialect: W3C Feb. 22, 2022 11:20:35 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch WARNUNG: Unable to find an exact match for CDP version 98, so returning the closest version found: 97 Feb. 22, 2022 11:20:35 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch INFORMATION: Found CDP implementation for version 98 of 97 – stackedgorilla Feb 22 '22 at 22:27
  • Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot determine loading status from disconnected: received Inspector.detached event (Session info: chrome=98.0.4758.102) Build info: version: '4.1.2', revision: '9a5a329c5a' System info: host: 'ADMIN-PC', ip: '10.9.9.5', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.1' Driver info: org.openqa.selenium.chrome.ChromeDriver – stackedgorilla Feb 22 '22 at 22:27
  • Command: [36616fc49aa8fb6371b9234cdf060a75, get {url=https://www.google.com}] Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 98.0.4758.102, chrome: {chromedriverVersion: 98.0.4758.102 (273bf7ac8c90..., userDataDir: F:\AppData\Local\Temp\scope...}, goog:chromeOptions: {debuggerAddress: localhost:13952}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), – stackedgorilla Feb 22 '22 at 22:29
  • se:cdp: ws://localhost:13952/devtoo..., se:cdpVersion: 98.0.4758.102, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true} at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at – stackedgorilla Feb 22 '22 at 22:29
  • java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200) at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133) at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53) – stackedgorilla Feb 22 '22 at 22:30
  • at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184) 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:558) at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:327) at extras.testclass.main(testclass.java:18) – stackedgorilla Feb 22 '22 at 22:30
  • @stackedgorilla The previous error **Driver info: org.openqa.selenium.chrome.ChromeDriver** seems to be have got resolved now and _Unable to find an exact match for CDP version 98, so returning the closest version found: 97_ sounds to be a new error all together. Feel free to raise a new question with your new requirement. – undetected Selenium Feb 22 '22 at 22:34