简体   繁体   中英

Can't load google chrome driver in selenium java on linux

I've started using selenium over java in eclipse on linux (CentOS 6.6).

With Firefox everything works fine but with Chrome I'm getting:

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: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-504.el6.x86_64', java.version: '1.7.0_79'
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:116)
    at First.testGoogleSearch(First.java:24)
    at First.main(First.java:18)
Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:37:03'
System info: host: 'localhost.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-504.el6.x86_64', java.version: '1.7.0_79'
Driver info: driver.version: ChromeDriver
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:178)
    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)
    ... 8 more
Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:13244/status] to be available after 20001 ms
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:107)
    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:175)
    ... 11 more
Caused by: com.google.common.util.concurrent.UncheckedTimeoutException: java.util.concurrent.TimeoutException
    at com.google.common.util.concurrent.SimpleTimeLimiter.callWithTimeout(SimpleTimeLimiter.java:143)
    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:80)

What I've tried:

  1. Changing the SetProperty to path to real path instead of symlink. That's following additional stack-overflow posts on the issue which suggested the above.

  2. Installing a higher version of Java (using 1.7, installed 1.8).

That's my code, help would be appreciated:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxProfile;


public class First {

    /**
     * @param args
     * @throws InterruptedException 
     */
    public static void main(String[] args) throws InterruptedException {
        // TODO Auto-generated method stub
        testGoogleSearch();
    }
    public static void testGoogleSearch() throws InterruptedException {
      //System.setProperty("webdriver.chrome.driver", "//home//shai//selenium//chromedriver");    
      System.setProperty("webdriver.chrome.driver", "//etc//alternatives//google-chrome");
      WebDriver driver = new ChromeDriver();
      driver.get("http://some url");
      driver.quit();
    }


}

There are various possibilities for this issue to occured.

Please check the chromedriver is whether 32 bit or 64 bit. It must match with your OS.

OR

It might be the because of folder permission. Please give execute permission to the folder where chromedriver is located.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM