Thanks for your replay @David and @Marcin

@Marcin

> I'm not sure that I like your solution with traits as it again hides the 
> context of which page we're currently on.

So am I. This trait solution is some kind of bridge or even try between my 
strong typed thinking in dynamically language. I liked what you said about 
how you write your specs.

W dniu piątek, 3 lutego 2017 14:44:05 UTC+1 użytkownik 
[email protected] napisał:
>
> 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 code
>
>> source: 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 
User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/geb-user/ee36b651-2ca0-4dae-91ad-51ec5680243c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to