1

以下是我的页面和规格。我可以输入 的值,firstName但我收到以下错误lastName我认为我们可以在这里http://www.gebish.org/manual/current/navigator.html#text_inputs_and_textareas使用基于 Geb doc 的 '=' 运算符来分配值

geb.error.UnresolvablePropertyException: Unable to resolve lastName as a property to set on NewConsumerApplicationPage's Navigator context
    at geb.content.NavigableSupport.propertyMissing(NavigableSupport.groovy:141)
    at geb.Browser.propertyMissing(Browser.groovy:182)
    at geb.spock.GebSpec.propertyMissing(GebSpec.groovy:59)
    at WorkItemSpec.Create workitem(WorkItemSpec.groovy:32)

class NewConsumerApplicationPage extends Page
{static content =
    {
        newApplicationForm
        { $("form", id: "newApplicationConsumerForm") }

        firstName
        {newApplicationForm.find("input", id: "newApplication_primaryApplicant:consumerIdentification:firstName")}

        lastName
        {newApplicationForm.find("input", id: "newApplication_primaryApplicant:consumerIdentification:lastName")}

        submitButton
        {
            $("button", id: "newConsumerApplication_submit")
        }
    }
}

规格

def "Create workitem"()
{
    given : "I am successfully logged into the application"
    to NewConsumerApplicationPage

    when:
    firstName.value "CCERASTOSTIGMA"
    lastName = "PAULA"

    submitButton.click()

    then : 
    at ApplicationSummaryPage
}
4

1 回答 1

2

我从 Geb 邮件列表中得到了答案。为了大家的利益,把它贴在这里。

这有点令人困惑,但是手册的这一部分是“表单控件快捷方式”的一部分,即它只适用于表单内容元素。假设您的表单有一个name=lastName输入元素,这将起作用:

newApplicationForm.lastName = 'value'

但是,当使用 . 手动选择表单的输入元素时,它不起作用$/find

于 2012-03-28T12:37:49.540 回答