簡體   English   中英

在grails中使用selenium-rc進行測試

[英]testing using selenium-rc in grails

我的項目沒有通過硒測試。

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")
    }
}

運行命令“ test-app is時顯示輸出STS:

com.thoughtworks.selenium.SeleniumException在30000毫秒后超時:com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91)在com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)處超時at grails.plugins.selenium.SeleniumWrapper.open(SeleniumWrapper.groovy:53)at grails.plugins.selenium.meta.AndWaitDynamicMethod.invoke(AndWaitDynamicMethod.groovy:32)at grails.plugins.selenium.SeleniumWrapper.methodM :125)at automation.HomeTests.testHomepageLoads(HomeTests.groovy:14)

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

命令歷史記錄為 :getTitle()setContext(a87ff87c1ae249be99c6363519627de8)windowMaximize()setContext(HomeTests:測試主頁加載)open(http://www.facebook.com/login.php,true)

您的PATH變量中有firefox嗎? Selenium需要從安裝目錄啟動firefox實例,並需要知道該目錄在哪里。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM