无法通过Ubuntu上的Selenium RC服务器启动Google Chrome

问题描述:

我在Ubuntu 11.04上运行Selenium RC server 2.0b3。我安装了谷歌浏览器,并试图对它进行一些测试。我能够对Firefox运行测试就好了。但是,当我对Selenium服务器运行我的测试时,它会挂起然后超时。这是所有的服务器日志报告(注意空会话):无法通过Ubuntu上的Selenium RC服务器启动Google Chrome

16:14:16.810 INFO - Command request: getNewBrowserSession[*googlechrome, http://mydomain.com, ] on session null 
16:14:16.810 INFO - creating new remote session 
16:14:16.811 INFO - Allocated session 6913c9613c554db798e109eadefd43da for http://mydomain.com, launching... 
16:14:16.811 INFO - Launching Google Chrome... 
16:19:44.776 ERROR - Failed to start new browser session, shutdown browser and clear all session data 
org.openqa.selenium.server.RemoteCommandException: timed out waiting for window 'null' to appear 
    at org.openqa.selenium.server.FrameGroupCommandQueueSet.waitForLoad(FrameGroupCommandQueueSet.java:564) 
    at org.openqa.selenium.server.FrameGroupCommandQueueSet.waitForLoad(FrameGroupCommandQueueSet.java:521) 
    at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSession(BrowserSessionFactory.java:374) 
    at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:125) 
    at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:87) 
    at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowserSession(SeleniumDriverResourceHandler.java:785) 
    at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResourceHandler.java:422) 
    at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDriverResourceHandler.java:393) 
    at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:146) 
    at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530) 
    at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482) 
    at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909) 
    at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820) 
    at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986) 
    at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837) 
    at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243) 
    at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357) 
    at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534) 
16:19:44.777 INFO - Killing Google Chrome... 
16:19:44.777 INFO - Got result: Failed to start new browser session: Error while launching browser on session null 

我开始硒作为系统启动服务,像这样......

start() { 
    log_daemon_msg "Starting selenium-server server: " 
    /usr/bin/Xvfb :15 -ac -screen 0 1024x768x8 & 
    export DISPLAY=localhost:15.0 
    su selenium -c 'java -jar /opt/selenium/selenium-server-standalone-2.0b3.jar -userExtensions /opt/selenium/user-extensions.js > /var/log/se_rc_server.log 2>&1 &' 
    PID=$! 
    ### Create the lock file ### 
    echo $PID > /var/run/selenium-server.pid 
    echo 

任何想法如何,我可以消除Google Chrome空会话并让我的测试运行?谢谢, - Dave

+0

你能分享你的测试代码吗?连接到硒服务器的那个? – 2011-05-11 22:10:18

+1

你在'/ usr/bin/google-chrome'或其他地方有'google-chrome'吗? – 2011-05-11 22:11:42

您正在运行Chrome的安全限制。您需要在BrowserConfigurationOptions中将“mode”值设置为“disableSecurity”以禁用它们。

+0

你是如何做到这一点的?我试着用“铬浏览器 - 禁用网络安全”内容创建一个“/ usr/bin/google-chrome”文件,但那不起作用。 – Dave 2011-05-12 16:34:44

+0

我不知道你在用什么语言,但是在Java中你会调用'set()'方法。这里是JavaDocs(适应你使用的任何语言应该是直截了当的):http://selenium.googlecode.com/svn/trunk/docs/api/java/com/thoughtworks/selenium/BrowserConfigurationOptions.html – nirvdrum 2011-05-14 15:44:07

+0

是你是否等同于使用“--disable-web-security”选项启动Google Chrome/Chromium?我使用HttpCommandProcessor类来发送命令(http://release.seleniumhq.org/selenium-remote-control/0.9.0/doc/java/com/thoughtworks/selenium/HttpCommandProcessor.html),它不包括一个BrowserConfiguration选项,所以我正在寻找另一种方法来做同样的事情。 – Dave 2011-05-16 17:01:39