Given a geb.Page
like:
class ConsultaPage extends Page {
static url = "web/search-basic"
static content = {
titol { $('h4',0).text() }
searchBox { $(name: "criteria").module(TextInput) }
searchButton { $(By.id("submit_button")) }
seriesBuscadorButton { $('img', src:"/web/resources/img/find") }
}
static at = {
$("#serveis h2").text() == "Menú consulta"
}
void openSeriesBuscador(){
seriesBuscadorButton.click()
}
}
And a Spec like:
class id_3031_PageSpec extends BaseGebSpec {
def "login ok com usuari normal accedeix a consulta i obre minibuscador series"(){
given:
via iArxiuPage
when:
// unrelated stuff...
then:
to ConsultaPage
and:
//this works -> $('img', src:"/refweb/resources/img/find")*.click()
//this also works-> seriesBuscadorButton.click()
openSeriesBuscador()
then:
titol.equals("Cerca i selecció de sèrie")
}
}
(BaseGebSpec is just a GebSpec with common setupSpec() for reading commons properties to all specs)
If I run this I get:
Condition not satisfied:
openSeriesBuscador()
|
null
Condition not satisfied:
openSeriesBuscador()
|
null
If instead of using:
openSeriesBuscador()
method (that uses a content variable with the same $() logic)
I use $('img', src:"/refweb/resources/img/find").click()
or seriesBuscadorButton.click()
it works perfectly.
I think I 'm not understanding properly the content variables functionalities or accessing ways, but I'm not been able to find it looking at Geb Book. Can anyone help me to understand that behaviour?
Why accessing static content variable inside a method's Page fail but not accesing from the Spec class? Thanks in advance!