2012-03-22 59 views
1

下面是我的頁面和規格。我可以輸入firstName的值,但我得到lastName的以下錯誤。我以爲我們可以根據蓋布DOC這裏http://www.gebish.org/manual/current/navigator.html#text_inputs_and_textareas爲輸入類型文本分配表單值時出現混亂

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 
} 

回答

2

我已經得到了來自Geb郵件列表的答覆。在這裏發佈它爲了大家的利益。

這有點令人困惑,但本手冊的這一部分是 「表格控件快捷方式」的一部分,即它僅適用於表格內容 元素。假設你的表格上name=lastName輸入元素,這 將工作:

newApplicationForm.lastName = 'value' 

但是,它沒有手動選擇使用$/find一個 形式的輸入元素時工作。