2

对于我们的集成测试,我们使用 selenium 和 Chrome、Firefox 和 IE 的不同(版本)驱动程序。我们的构建服务器上没有 UI(或 X),即无头。我们将 Xvfb 用于虚拟屏幕(帧缓冲区)。

如果我在具有 X(UI)的本地计算机上运行它,则不会出现错误。

我有一个足够简单的测试类:

import java.io.IOException;
import java.net.URL;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class Test {

    public static void main(String[] args) throws IOException, InterruptedException {
        WebDriver driver = new RemoteWebDriver(new URL("http://localhost:9515"), DesiredCapabilities.chrome());
        driver.get("http://www.google.com");
        Thread.sleep(2000);
        driver.quit();
    }

然后我在端口 9515 上启动 chromedriver。我得到的例外是:

abc@xyz:~/test$ java -cp $CLASSPATH Test

(google-chrome:22323): Gtk-WARNING **: cannot open display: 
[0124/165659:ERROR:ipc_sync_channel.cc(378)] Canceling pending sends
chrome/test/automation/proxy_launcher.cc:107: Failure
Value of: app_launched
  Actual: 5
Expected: AUTOMATION_SUCCESS
Which is: 0
Error while awaiting automation ping from browser process
[0124/165659:ERROR:automation_proxy.cc(319)] Channel error in AutomationProxy.
[0124/165659:ERROR:ipc_sync_channel.cc(378)] Canceling pending sends
[0124/165659:ERROR:ipc_sync_channel.cc(378)] Canceling pending sends
Exception in thread "main" org.openqa.selenium.WebDriverException: Unable to either launch or connect to Chrome. Please check that ChromeDriver is up-to-date. Using Chrome binary at: /opt/google/chrome/google-chrome (WARNING: The server did not provide any stacktrace information); duration or timeout: 223 milliseconds
Build info: version: '2.9.0', revision: '14289', time: '2011-10-20 23:22:17'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.32-28-server', java.version: '1.6.0_26'
Driver info: driver.version: RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:147)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:113)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:417)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:115)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:76)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:84)
    at Test.main(Test.java:63)

我一直在广泛搜索并尝试了许多不同的方法。由于我已经尝试解决这个问题超过 2 天,我可能会忽略一个小细节。

我在用着:

$ uname -a
Linux bryant 2.6.32-28-server #55-Ubuntu SMP Mon Jan 10 23:57:16 UTC 2011 x86_64 GNU/Linux

google-chrome-stable 24.0.1312.56-r177594 chromedriver_linux64_23.0.1240.0, chromedriver_linux64_26.0.1383.0

对此有什么想法吗?

4

0 回答 0