2015-05-05 63 views
2

我试图运行与硒的webdriver Linux服务器与镀铬和无显示 这是我的java代码在Linux服务器上运行Selenium测试的webdriver

 System.setProperty("webdriver.chrome.driver","/home/exploit/Bureau/chromedriver"); 
     WebDriver driver = new ChromeDriver(); 
     driver.get("https://www.google.com"); 
     WebElement element = driver .findElement(By.id("lst-ib")); 

运行此程序上实现的测试(JAR )一个用命令

Xvfb :1 -screen 5 1024x768x8 & 
export DISPLAY=:1.5 

启动Xvfb来当我运行后我有点漫长的等待

12:39:53.483 [Forwarding newSession on session null to remote] DEBUG   o.a.h.i.conn.DefaultClientConnection - Connection 0.0.0.0:51411<->127.0.0.1:9069 closed 
12:39:53.483 [Forwarding newSession on session null to remote] DEBUG o.a.h.i.conn.tsccm.ConnPoolByRoute - Notifying no-one, there are no waiting threads 
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally 
(Driver info: chromedriver=2.9.248304,platform=Linux 3.10.0-123.13.2.el7.x86_64 x86_64) (WARNING: The server did not provide any stacktrace information) 
    Command duration or timeout: 60.69 seconds 
    Build info: version: 'unknown', revision: 'unknown', time: 'unknown' 
    System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0- 123.13.2.el7.x86_64', java.version: '1.7.0_79' 
    Driver info: driver.version: ChromeDriver 
    Session ID: 6c811fab5c809544094e1f9e1d96ef6a 
     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) 
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526) 
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:188) 
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145) 
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:531) 
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:215) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:110) 
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:114) 
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:161) 
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:107) 
    at com.atos.esope.Extractor.extTest(Extractor.java:76) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:606) 
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317) 
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:201) 
    at com.sun.proxy.$Proxy27.extTest(Unknown Source) 
    at com.atos.esope.Program.main(Program.java:32) 
得到这个例外的程序210

,当我尝试单独运行Chrome浏览器有这个问题

Xlib: extension "RANDR" missing on display ":1.5". 
Xlib: extension "RANDR" missing on display ":1.5". 
Xlib: extension "RANDR" missing on display ":1.5". 
Xlib: extension "RANDR" missing on display ":1.5". 
Xlib: extension "RANDR" missing on display ":1.5". 
Xlib: extension "RANDR" missing on display ":1.5". 
Xlib: extension "RANDR" missing on display ":1.5". 
[3207:3207:0505/171255:ERROR:url_pattern_set.cc(240)] Invalid url pattern:   chrome://print/* 
libGL error: failed to load driver: swrast 
libGL error: Try again with LIBGL_DEBUG=verbose for more details. 
libGL error: failed to load driver: swrast 
libGL error: Try again with LIBGL_DEBUG=verbose for more details. 
libGL error: failed to load driver: swrast 
libGL error: Try again with LIBGL_DEBUG=verbose for more details. 
libGL error: failed to load driver: swrast 
libGL error: Try again with LIBGL_DEBUG=verbose for more details. 
libGL error: failed to load driver: swrast 
libGL error: Try again with LIBGL_DEBUG=verbose for more details. 
libGL error: failed to load driver: swrast 
libGL error: Try again with LIBGL_DEBUG=verbose for more details. 

的问题是:

是定位驱动器或Chrome的问题,或者我需要一些额外的配置?

+0

尝试乌尔Linux操作系统中执行./chromedriver告诉我输出 –

+0

开始ChromeDriver在端口9515(v2.9.248304) –

+0

难道U盘了一切作为chromedriver wiki ??? – SkorpEN

回答

2

我尝试过使用Firefox.You需要引导Firefox,以便它在Xvfb中执行。

你可以尝试以下方法:

String Xport = System.getProperty("lmportal.xvfb.id", ":1"); 

final File firefoxPath = new File(System.getProperty("lmportal.deploy.firefox.path", "/usr/bin/firefox")); 

FirefoxBinary firefoxBinary = new FirefoxBinary(firefoxPath); 

firefoxBinary.setEnvironmentProperty("DISPLAY", Xport); 
相关问题