abracadabra
abracadabra

Reputation: 381

UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server with ChromeDriver

Code

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

import java.io.File;
import java.util.HashMap;

public class tttt {
    public static void main(String[] args) throws InterruptedException {
        ChromeOptions options = new ChromeOptions();
        HashMap<String, Object> chromePrefs = new HashMap<>();
        //mePrefs.put("download.default_directory", new File(RobotPay.class.getClassLoader().getResource("alipaycaptchatmp/").getFile()).getAbsolutePath());
        chromePrefs.put("download.prompt_for_download", false);
        chromePrefs.put("download.directory_upgrade", true);
        chromePrefs.put("safebrowsing.enabled",true);
        chromePrefs.put("profile.managed_default_content_settings.images", 2);//禁图片
        options.setExperimentalOption("prefs", chromePrefs);
        options.addArguments("--headless");
        options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
        options.addArguments("--no-sandbox"); // Bypass OS security model

        System.setProperty("webdriver.chrome.driver", args[0]);
        options.setBinary(args[1]);


        ChromeDriver dr = new ChromeDriver(options);


    }
}

error:

[qateadmin@UAT13352 ~]$ java -cp "/opt/tars/apps/100018485/releases/762245/WEB-INF/lib/*:./" tttt /opt/tars/apps/100018485/releases/762245/WEB-INF/classes/seleniumdriver/chromedriver /usr/bin/google-chrome
Starting ChromeDriver 2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5) on port 4461
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'UAT13352', ip: '10.5.117.188', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-327.4.5.el7.x86_64', java.version: '1.7.0_51'
Driver info: driver.version: ChromeDriver
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
        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:170)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)
        at tttt.main(tttt.java:25)
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...
        at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:76)
        at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:171)
        at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:185)
        at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177)
        at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
        ... 7 more

chrome version:

[qateadmin@UAT13352 ~]$ google-chrome -version
Google Chrome 71.0.3578.98

chrome executable mode is 777

chromedriver version:2.45(Supports Chrome v70-72,mode is 777)

OS:centos_x64

Also, i have tested it on my local Ubuntu16.04_x64 and CentOS7_x64 virtual machine with no exception. I am stuck at this problem,any suggestion?


updates
after upgraded java to Java SE 8u191,the error messages now is:

[qateadmin@UAT13352 ~]$ java -cp "/opt/tars/apps/100018485/releases/762245/WEB-INF/lib/*:./" tttt /opt/tars/apps/100018485/releases/762245/WEB-INF/classes/seleniumdriver/chromedriver /usr/bin/google-chrome
Starting ChromeDriver 2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5) on port 3602
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'UAT13352', ip: '10.5.117.188', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-327.4.5.el7.x86_64', java.version: '1.8.0_191'
Driver info: driver.version: ChromeDriver
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:665)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
        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:170)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
        at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:148)
        at tttt.main(tttt.java:25)
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...
        at org.apache.commons.exec.DefaultExecuteResultHandler.getException(DefaultExecuteResultHandler.java:76)
        at org.openqa.selenium.os.UnixProcess.checkForError(UnixProcess.java:171)
        at org.openqa.selenium.os.CommandLine.checkForError(CommandLine.java:185)
        at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:177)
        at org.openqa.selenium.remote.service.DriverService.start(DriverService.java:166)
        at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:78)
        at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:644)
        ... 7 more

Upvotes: 2

Views: 1603

Answers (1)

undetected Selenium
undetected Selenium

Reputation: 193298

This error message...

Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '2.53.1', revision: 'a36b8b1cd5757287168e54b817830adce9b0158d', time: '2016-06-30 19:26:09'
System info: host: 'UAT13352', ip: '10.5.117.188', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-327.4.5.el7.x86_64', java.version: '1.7.0_51'
.
Caused by: java.lang.IllegalStateException: The process has not exited yet therefore no result is available ...

...implies that the ChromeDriver was unable to initiate/spawn a new WebBrowser i.e. Chrome Browser session.

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

  • Your JDK version is 1.7.0_51 which is pretty ancient.
  • Your Selenium Client version is 2.53.1 of 2016-06-30 19:26:09 which is almost 3 years older.

So there is a clear mismatch between the JDK v7u51, Selenium Client v2.53.1, ChromeDriver v2.45 and Google Chrome 71.0.3578.98.

Solution

  • Upgrade JDK to recent levels JDK 8u191.
  • Upgrade Selenium to current levels Version 3.141.59.
  • Upgrade ChromeDriver to current ChromeDriver v2.45 level.
  • Keep Chrome version between Chrome v670-72 levels. (as per ChromeDriver v2.42 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
  • Take a System Reboot.
  • Execute your @Test.

Upvotes: 1

Related Questions