2012-02-08 37 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