Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome 在无显示器的ubuntu机器下使用selenium_Google Chrome_Selenium_Selenium Webdriver_Selenium Chromedriver - Fatal编程技术网

Google chrome 在无显示器的ubuntu机器下使用selenium

Google chrome 在无显示器的ubuntu机器下使用selenium,google-chrome,selenium,selenium-webdriver,selenium-chromedriver,Google Chrome,Selenium,Selenium Webdriver,Selenium Chromedriver,我找不到一种在ubuntu机器下运行selenium的方法,没有显示 我有以下java代码: public static void main(String args[]){ String url = args[0]; WebDriver driver = new ChromeDriver(); String scriptToExecute = "var network = performance.getEntries() || {}; retu

我找不到一种在ubuntu机器下运行selenium的方法,没有显示

我有以下java代码:

public static void main(String args[]){
        String url = args[0];

        WebDriver driver = new ChromeDriver();

        String scriptToExecute = "var network = performance.getEntries() || {}; return network;";

        driver.navigate().to(url);
        String netData = ((JavascriptExecutor)driver).executeScript(scriptToExecute).toString();

        System.out.println(netData);
    }
这段代码在我的本地机器上运行良好,但在我的ubuntu服务器上不起作用。 这是在“driver.navigate().to(url);”上引发的异常:

我想这个问题与我的ubuntu服务器上没有显示有关

这是我在ubuntu服务器上安装的依赖项:

  • libnss3
  • GConf-2.4
  • libfontconfig
  • 谷歌浏览器稳定

有没有办法克服这个问题?

使用Xvfb作为虚拟无头显示器?幻影如何?
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: org.openqa.selenium.NoSuchSessionException: no such session
  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.8.0-51-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 37 milliseconds
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'craw-temp', ip: '10.132.0.56', os.name: 'Linux', os.arch: 'amd64', os.version: '4.8.0-51-generic', java.version: '1.8.0_131'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: Chrome failed to start: exited abnormally
  (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.8.0-51-generic x86_64), platform=ANY}]
Session ID: de392db337e4adbd5876d2b8c5ca105c
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635)
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:322)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteNavigation.to(RemoteWebDriver.java:902)
    at it.thirdplace.crawlertag_be.SeleniumChrome2.main(SeleniumChrome2.java:45)
    ... 5 more