2017-06-11 68 views
0

我已經開始在Eclipse上使用eclipse上的selenium(CentOS 6.6)。無法在linux上的selenium java中加載谷歌瀏覽器驅動程序

與Firefox一切工作正常,但在Chrome我越來越:

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) 

我已經試過:

  1. 而setProperty到路徑更改爲實際路徑,而不是符號鏈接。 這是關於建議上述問題的其他堆棧溢出帖子。

  2. 安裝更高版本的Java(使用1.7,安裝1.8)。

這是我的代碼,幫助將不勝感激:

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(); 
    } 


} 
+1

什麼是你的鉻驅動程序和瀏覽器版本 –

回答

0

有各種可能性,這個問題發生。

請檢查chromedriver是否是32位或64位。它必須與您的操作系統匹配。

OR

這可能是文件夾權限的原因。請將執行權限授予chromedriver所在的文件夾。

+0

操作系統和驅動程序是64位(爲了以防萬一,嘗試32)。文件夾具有執行權限 –

相關問題