Groovy 有人能解释一下geb页面内容DSL中的语法吗?

Groovy 有人能解释一下geb页面内容DSL中的语法吗?,groovy,syntax,spock,dsl,geb,Groovy,Syntax,Spock,Dsl,Geb,我无法理解Geb中描述(定义)页面的语法。下面是一个页面类示例,它工作得很好,但我不理解它是如何工作的 import geb.Page class GebHomePage extends Page{ static url = "http://gebish.org" static at = { title == "Geb - Very Groovy Browser Automation" } static content = { seeGuideBut

我无法理解Geb中描述(定义)页面的语法。下面是一个页面类示例,它工作得很好,但我不理解它是如何工作的

import geb.Page

class GebHomePage extends Page{
    static url = "http://gebish.org"

    static at = { title == "Geb - Very Groovy Browser Automation" }

    static content = {
        seeGuideButton { $('div', class:'ui huge primary button') }
        uiHeader { $('h1', class:'ui header', 0)}
    }
}
我对内容引用的闭包内部的语法感兴趣。Geb将内容DSL的语法描述为

«name»(«options map») { «definition» }
我不懂这个语法。名称部分看起来像一个变量,但它没有声明(我缺少一个def或类似的东西),最后一部分看起来像一个闭包。但是名称和闭包之间的连接在哪里呢。两者之间没有等号。在标准groovy类中,语法

«name» { «definition» }

不编译。在内容DSL的一行中发生了什么?
ui标题
seeGuideButton
究竟是什么,它们与以下闭包有什么关系?这个语法到底是如何工作的?

在幕后,Geb寻找一个带有签名的方法:

uiHeader(Map, Closure)
在groovy中,您可以捕获方法丢失的时间(请参见methodMissing),因此Geb将在内部捕获该时间,并知道如何解决将来对该变量的任何请求

同样在groovy中,作为最后一个参数的闭包可以在括号外,这就是为什么可以这样做

uiHeader(required: false) { $('h1') }

仅供参考,处理内容定义的
methodMissing()
可以在
PageContentTemplateBuilder
中找到