2011-05-11 101 views
1

我在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

回答

0

您正在運行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

相關問題