从命令行启动时,Selenium和Chromedriver不会互相交谈

时间:2013-01-24 06:51:26

标签: java selenium-chromedriver

对于我们的集成测试,我们使用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

有关于此的任何想法吗?

0 个答案:

没有答案