0

Hi i'm unable to run sample test .java program using chrome-driver with no-sandbox option turned on,

  • Distributor ID: Ubuntu
  • Description: Ubuntu 18.04.5 LTS
  • Release: 18.04
  • Codename: bionic
  • selenium-server-standalone-3.14.0.jar
  • ChromeDriver 86.0.4240.22
  • openjdk version "11.0.8" 2020-07-14
  • OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
  • OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode)

root@root:~/test# export CLASSPATH=".:selenium-server-standalone-3.14.0.jar:testng-6.8.7.jarj:unit-4.13.jar"

import org.openqa.selenium.*;
import org.openqa.selenium.chrome.*;
import org.junit.Test;
import java.io.IOException;


public class GettingStarted {
  @Test
    // Optional. If not specified, WebDriver searches the PATH for chromedriver.
          public static void main(String[] args) throws IOException, InterruptedException {

System.setProperty("webdriver.chrome.driver", "/usr/lib/chromium-browser/chromedriver");
ChromeOptions opt = new ChromeOptions();
opt.addArguments("--no-sandbox");
//opt.setBinary("/usr/bin/google-chrome");
opt.addArguments("--headless") ;



    WebDriver driver = new ChromeDriver();

   driver.get("http://www.google.com/");
    Thread.sleep(5000);  // Let the user actually see something!
    WebElement searchBox = driver.findElement(By.name("q"));
    searchBox.sendKeys("ChromeDriver");
    searchBox.submit();
    Thread.sleep(5000);  // Let the user actually see something!
    driver.quit();
  }
}

error

Starting ChromeDriver 86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378}) on port 14930
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.WebDriverException: unknown error: Chrome failed to start: exited abnormally.
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:13:22.693Z'
System info: host: 'root', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-117-generic', java.version: '11.0.8'
Driver info: driver.version: ChromeDriver
remote stacktrace: #0 0x55d315b85d99 <unknown>

        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
        at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$new$0(W3CHandshakeResponse.java:57)
        at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$getResponseFunction$2(W3CHandshakeResponse.java:104)
        at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:122)
        at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
        at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
        at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
        at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
        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:543)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:125)
        at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
        at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)
        at GettingStarted.main(GettingStarted.java:20)
asadz
  • 174
  • 15
  • 1
    seems like you're not setting the driver to use your options... so, WebDriver driver = new ChromeDriver(opt); (Also check your Chrome browser version to see that it is 86) – pcalkins Sep 21 '20 at 17:34
  • it solved now i'm getting `xception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 86` – asadz Sep 21 '20 at 17:57
  • 1
    update Chrome browser and you should be good to go. – pcalkins Sep 21 '20 at 18:00

0 Answers0