参数化Geb模块在某种情况下不起作用

时间:2017-02-28 09:22:15

标签: groovy geb

我正在编写Geb测试,我想使用参数化模块,但我似乎无法使其正常工作。 这是我的页面对象:

class CreateNewOrganizationPage extends Page {

    static url = "/organization/create"

    static content = {
        organizationTypes { module MultiSelect, id: "orgTypeIds" }           
    }
}

这是我的模块:

class MultiSelect extends Module {
    def id

    static content = {
        caret {  $("#" + id + "-caret") }
    }
}

这就是我在测试中使用它的方式:

when:
to CreateNewOrganizationPage
organizationTypes.caret.click()

这似乎与此网站上的情况相同: http://swalsh.org/blog/2014/06/25/groovy-browser-automation-with-geb/

我在这里做错了什么?因为我在stacktrace中得到以下异常:

groovy.lang.MissingMethodException: No signature of method: geb.content.PageContentTemplateFactoryDelegate.module() is applicable for argument types: (java.util.LinkedHashMap, java.lang.Class) values: [[id:orgTypeIds], class pages.management.MultiSelect]
Possible solutions: module(java.lang.Class), module(java.util.Map, java.lang.Class), module(geb.Module), module(java.lang.Class, java.lang.Object), module(java.util.Map, java.lang.Class, geb.navigator.Navigator), dump()

    at geb.content.PageContentTemplateFactoryDelegate.module(PageContentTemplateFactoryDelegate.groovy:49)
    at pages.management.CreateNewOrganizationPage._clinit__closure1$_closure3(CreateNewOrganizationPage.groovy:43)
    at pages.management.CreateNewOrganizationPage._clinit__closure1$_closure3(CreateNewOrganizationPage.groovy)
    at geb.content.PageContentTemplate.invokeFactory(PageContentTemplate.groovy:97)
    at geb.content.PageContentTemplate.create_closure1(PageContentTemplate.groovy:59)
    at geb.content.PageContentTemplate.create_closure1(PageContentTemplate.groovy)
    at geb.content.PageContentTemplate.create(PageContentTemplate.groovy:82)
    at geb.content.PageContentTemplate.get(PageContentTemplate.groovy:54)
    at geb.content.DefaultPageContentSupport.getContent(DefaultPageContentSupport.groovy:42)
    at geb.content.PageContentSupport.propertyMissing(PageContentSupport.groovy:39)
    at geb.Page.propertyMissing(Page.groovy:112)
    at geb.Browser.propertyMissing(Browser.groovy:216)
    at geb.spock.GebSpec.propertyMissing(GebSpec.groovy:60)
    at ManagementSpec.create new organization(ManagementSpec.groovy:21)

修改 问题解决了:

specialDatePicker { module(new DatePicker(id: "someId")) }

现在有效!

0 个答案:

没有答案