Answer a question

I'm trying to run a test implemented with selenium webdriver on a Linux server with chrome and no display this my java code

        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"));

to run this program (jar) a start the Xvfb with the command

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

when I run the program I got this Exception after a bit long waiting

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)

and when I try to run chrome separately a got this problem

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.

the questions are :

is the problem in locating the driver or in chrome or I need some additional configuration ?

Answers

I have tried it using Firefox.You need to guide Firefox so that it executes in the Xvfb.

You can try the following:

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);
Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐