testing - Geb:如何注册意外页面

标签 testing automation spock geb

我在 GebConfig.groovy 中注册了一个意外的页面,如下所示:

unexpectedPages = [EmptySearchResultPage]

页面类如下:

import geb.Page

class EmptySearchResultPage extends Page{
    static at = {
//      errorTitle.displayed
         $("h1",text:contains('Sorry… We Found No XXX.')) 
        }
    static content = {
        errorTitle(wait:true,required:false) { $("h1",text:contains('Sorry… We Found No XXX.')) }
    }
}

但我遇到以下异常:

geb.error.InvalidGebConfiguration: Unexpected pages configuration has to be a collection of classes that extend geb.Page but found "[[:]]". Did you forget to include some imports in your config file?
    at geb.Configuration.getUnexpectedPages(Configuration.groovy:189)
    at geb.Browser.doCheckIfAtAnUnexpectedPage(Browser.groovy:416)
    at geb.Browser.checkIfAtAnUnexpectedPage(Browser.groovy:402)
    at geb.Page.verifyAt(Page.groovy:181)
    at geb.Browser.doAt(Browser.groovy:454)
    at geb.Browser.at(Browser.groovy:353)
    at geb.Browser.to(Browser.groovy:568)
    at geb.Browser.to(Browser.groovy:556)
    at geb.Browser.to(Browser.groovy:523)
    at geb.spock.GebSpec.methodMissing(GebSpec.groovy:56)
    at com.skygate.global.HomePageTest.Open Homepage(HomePageTest.groovy:59)

我犯了什么错误? 请帮忙。谢谢。

最佳答案

错误信息是这样说的:

Did you forget to include some imports in your config file?

因此,假设您的页面不在默认包中(JVM 不喜欢这样!),您需要将其导入 GebConfig。

关于testing - Geb:如何注册意外页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42336194/

相关文章:

ruby - 如何在 watir 中定位特定图像?

testing - JUnit:如何测试样本列表?

ruby-on-rails - 让 Rails 测试知道 Rails 内部链之外的 Rack 中间件

.net - 使用浮点值进行单元测试

c++ - 如何使我的项目易于设置?

java - 从 Java 类中运行 Tomcat 服务器 - ProcessBuilder

grails - 在 grails 应用程序中使用 spock 验证空白约束的问题

spring - 并行运行 Spock 测试

testing - 无法将值传递给测试用例中的输入字段

node.js - JavaScript函数;在本地工作但不适用于 Lambda Minibootcamp