Re: [geb-dev] Page Object Pattern Implementation

Skip to first unread message
Message has been deleted

Marcin Erdmann

Feb 3, 2017, 8:29:58 AM2/3/17
Łukasz, would you mind moving this discussion to the user mailing list as it's a better fit for it? This list is supposed to be about development of Geb itself not about using it.


On Fri, Feb 3, 2017 at 1:26 PM, <> wrote:
Hello everyone, 

I'm a little confused about Page Object Pattern implementation at Geb. I'm talking about test classes extended from GebSpec/GebReportingSpec. I'm very impressed about Page implementation, especially about static url, content and at field but according to Martin Fowler blog and Simone Stewart (founder of WebDriver project):
If you have WebDriver APIs in your test methods, You're Doing It Wrong

Let's talk about this piece of code
import geb.Browser {
assert at(LoginPage)
.with {
= "admin"
= "password"
assert at(AdminPage)

This example is excellent prove that Geb doesn't implement Page Object Pattern in obvious way. In my opinion this is not full support for Page Object Pattern.
I think that Martin Fowler is right about:
The page object should encapsulate the mechanics required to find and manipulate the data in the gui control itself.

Previously, I was working a lot with pure WebDriver API and Java. When I started use Groovy I was very impressed for a moment. After that I realised that dynamically typed language like Groovy is very helpful but not in this case. I resolved this in inner trait. That's the example:

class MyPage extends Page {

static at = { ... }

static content = { element { ... } }

trait MyPageTrait {

def doSomethingOnMyElement() {


class MyTest extends GebSpec implements MyPage.MyPageTrait {

def "do some test"() {


What do you think about it? I'm open to have discuss. I'm not sure If I'm right but I've reason to think that Geb does it wrong. Please, fell free to suggest anything you like.


You received this message because you are subscribed to the Google Groups "Geb Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
To view this discussion on the web visit
For more options, visit

Reply all
Reply to author
0 new messages