Composing Geb Pages with Groovy Features

I have a responsive site, and I would like to highlight the problem that parts of my page template are dumped from the main content on the page:

trait DesktopPage { static content = { header { $('nav', id:'nav-container') } } } trait MobilePage { // other stuff } trait HomePage { static url = '' static at = { title == 'My Site' } } class DesktopHomePage extends Page implements DesktopPage, HomePage {} 

However, the Geb runtime does not seem to collect static description blocks from properties, but acts as if they were not present.

Is it possible to compose problems like this implicitly using traits with Geb? If not, is there any syntax that will allow me to extract information from implemented features? HomePage.at not allowed.

+5
source share
1 answer

If you look at the documentation for properties and static fields , you will notice that it explicitly mentions that mixing in the attribute declaring a static field does not add the field to the class. Geb was created before features were added to Groovy, so using them to compose a page was definitely not taken into account when developing the API.

If the url and checker are the same for both pages, and only the content is different from the mobile and desktop versions, why don't you just use inheritance?

 class HomePage { static url = '' static at = { title == 'My Site' } } class DesktopHomePage extends HomePage { static content = {...} } class MobileHomePage extends HomePage { static content = {...} } 
+1
source

Source: https://habr.com/ru/post/1202723/


All Articles