2012-02-08 38 views
0

我的項目沒有進行硒測試。在grails中使用硒-rc進行測試

的seleniumconfig.groovy有以下代碼:

selenium { 

slow = true 
singleWindow = true       
browser = "*iexploreproxy" 
url = null 
defaultTimeout = 60000     
windowMaximize = false  
screenshot { 
    dir = "./target/test-reports/screenshots" 
    onFail = false        
    } 
    server { 
    host = "localhost"       
    port = 4444        
    }     
} 

的NewTests.groovy文件包含以下代碼:

package gtunes 

import grails.plugins.selenium.* 
import org.junit.* 
import static org.junit.Assert.* 
import static org.hamcrest.Matchers.* 

@Mixin(SeleniumAware) 
class NewTests { 

class HomepageTests extends GroovyTestCase { 
    void testHomepageLoads() { 
     selenium.openAndWait "http://www.facebook.com/login.php" 
    assertTrue selenium.isTextPresent("facebook") 
    } 
} 

輸出STS是否顯示在運行命令「test-app是:

超時後30000ms com.thoughtworks.selenium.SeleniumException:30000ms 在com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97) 在com.thoughtworks.selenium.HttpCommandProcessor.doCommand(後超時HttpCommandProcessor.java:91) 在grails.plugins.selenium.SeleniumWrapper.open(SeleniumWrapper.groovy:53) 在grails.plugins.selenium.meta.AndWaitDynamicMethod.invoke(AndWaitDynamicMethod.groovy:32) 在grails.plugins。 seleniumWrapper.methodMissing(SeleniumWrapper.groovy:125) at automation.HomeTests.testHomepageLoads(HomeTests.groovy:14)

我的項目沒有通過測試。如何解決這個問題?

命令歷史記錄是:的getTitle() setContext(a87ff87c1ae249be99c6363519627de8) windowMaximize() setContext(HomeTests:測試網頁加載) 開放(http://www.facebook.com/login.php ,true)

+0

我從來沒有能夠從IDE啓動硒測試,你有沒有嘗試過從命令行? 'grails test-app -functional' – 2012-02-08 14:12:07

+0

我必須使用Spring源代碼套件來完成它。 – Shalini 2012-02-09 08:47:41

回答

0

你有PATH變量中的firefox嗎? Selenium需要從你的安裝目錄啓動firefox實例,並且需要知道你的目錄。

+0

我可以在哪裏找到PATH變量? – Shalini 2012-02-09 07:17:29

+0

如果您使用的是Windows 7,請嘗試[this](http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx) – 2012-02-09 07:56:32

0

我正面臨同樣的問題。你的設置對我來說很好。試試這個命令:
test-app :selenium