Below are my Page and Spec. I am able to enter the value for firstName
but I am getting the below error for lastName
. I thought we can assign the value using '=' operator based on Geb doc here 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)
Page
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")
}
}
}
Spec
def "Create workitem"()
{
given : "I am successfully logged into the application"
to NewConsumerApplicationPage
when:
firstName.value "CCERASTOSTIGMA"
lastName = "PAULA"
submitButton.click()
then :
at ApplicationSummaryPage
}
I've got the answer from Geb mailing list. Posting it here for everyone's benefit.
That's a bit confusing, but this section of the manual is part of the
"form control shortcuts", i.e. it only works on a form content
element. Assuming your form has a name=lastName
input element, this
would work:
newApplicationForm.lastName = 'value'
It does not work however when manually selecting input elements of a
form using $/find
.