Search code examples
spockgeb

Weak failure trace when using page object pattern with spock and geb


When using spock+geb you can assert that you are on expected page by assertion e.g.:

assert title == 'Sign In'

and you get a nice failure trace if assertion fails:

Condition not satisfied:

title == 'Sign In'
|     |
Login false
      5 differences (28% similarity)
      (Lo)g(i--)n
      (Si)g(n I)n

But if I try to use page object pattern e.g.:

class LoginPage extends GebPage {
    static at = { title == 'Sign In' }
}

Trace is not very helping what's going wrong:

Condition not satisfied:

at(LoginPage)
|
false

Is there any way how to use page object pattern and get more descriptive failure trace ?


Solution

  • According to geb mailing list responses the current workaround is:

    static at = { assert title == 'Sign In'; true }
    

    Thanks to David & Luke.