首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >硒在Grails上的功能测试失败

硒在Grails上的功能测试失败
EN

Stack Overflow用户
提问于 2011-07-14 23:23:41
回答 1查看 1K关注 0票数 0

我正在尝试将selenium测试与grails项目集成,但出现了一些问题。

我正在使用selenium-rc插件

代码语言:javascript
复制
grails install-plugin selenium-rc

以下是测试中的错误:

代码语言:javascript
复制
ERROR: Element username not found

com.thoughtworks.selenium.SeleniumException: ERROR: Element username not found
    at com.thoughtworks.selenium.HttpCommandProcessor.throwAssertionFailureExceptionOrError(HttpCommandProcessor.java:97)
    at com.thoughtworks.selenium.HttpCommandProcessor.doCommand(HttpCommandProcessor.java:91)
    at com.thoughtworks.selenium.DefaultSelenium.type(DefaultSelenium.java:291)
    at com.thoughtworks.selenium.Selenium$type$0.call(Unknown Source)
    at grails.plugins.selenium.SeleniumWrapper.type(SeleniumWrapper.groovy)
    at com.thoughtworks.selenium.Selenium$type.call(Unknown Source)
    at com.example.DashboardTests.testTeste(DashboardTests.groovy:25)

这只是一个测试,记录在我的应用程序中。

下面是测试代码:

代码语言:javascript
复制
import static org.hamcrest.Matchers.*
import static org.junit.Assert.*
import com.thoughtworks.selenium.*
import grails.plugins.selenium.*

import org.junit.*


@Mixin(SeleniumAware)
class DashboardTests extends GroovySeleneseTestCase{

    void testTeste() throws Exception {
        selenium.open("http://localhost:8080/login/auth")
        selenium.type("username", "user")
        selenium.type("password", "12345")
        selenium.clickAndWait("button")
    }
}

我不知道发生了什么,我认为这可能是配置,这是代码:

代码语言:javascript
复制
selenium {

    slow = false                                    // true to run tests in slow resources mode
    singleWindow = true                             // true for single window mode, false for multi-window mode
    browser = "*googlechrome"                       // can include full path to executable, default value is *firefox or *iexplore on Windows
    url = "http://localhost:8080/"                      // the base URL for tests, defaults to Grails server url
    defaultTimeout = 60000                          // the timeout after which selenium commands will fail
    windowMaximize = false                          // true to maximize browser on startup
    screenshot {
        dir = "./target/test-reports/screenshots"   // directory where screenshots are placed relative to project root
        onFail = false                              // true to capture screenshots on test failures
    }
    server {
        host = "localhost"                          // the host the selenium server will run on
        port = 4444                                 // the port the selenium server will run on
    }
    userExtensions = ""                             // path to user extensions javascript file

}

我使用chrome作为浏览器,因为firefox在我的项目中导致了错误。

如何解决?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-07-18 23:25:01

我解决了这个问题。

出现这个错误是因为我的测试环境没有上下文,这就是selenium无法访问数据的原因。

谢谢大家。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6695719

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档