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 https://martinfowler.com/bliki/PageObject.html 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 codesource: http://www.gebish.org/pages:
import geb.Browser
Browser.drive {
to LoginPage
assert at(LoginPage)
loginForm.with {
username = "admin"
password = "password"
}
loginButton.click()
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() {
element.click()
}
}
}
class MyTest extends GebSpec implements MyPage.MyPageTrait {
def "do some test"() {
expect:
doSomethingOnMyElement()
}
}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.Łukasz
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 geb-dev+unsubscribe@googlegroups.com.
To post to this group, send email to geb...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-dev/fc018393-9a8f-433d-9cb2-fcb061a0f24f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.