Encapsulating Page Logic Using GEB and Cucumber

Using GEB, I used the page object template to encapsulate information about different pages statically.

Then I reorganized my GEB code, which will be used from a separate class, so that I can encapsulate common commands with method calls.

For example, I will have a login () method that will call the appropriate GEB code to enter the website that I am testing. Then I would have other common functions using method calls in the TestHelper class.

I wanted to move these common functions to the pages they act on. For example, the search page will have a search method, the login page will have a login method. This way, I can create a library of pages that have common functionality for use in several GEB projects. Now, for this, each page must have a handle on geb.Browser, so now I will need to create an instance of each page in the test setup. By doing so, I can no longer use the standard page template template.

to ReviewQueuePage
assert at(ReviewQueuePage)

The null pointer will be indicated in the above code, since the object can no longer be accessed in static mode, which means that I had to change the code to

go ReviewQueuePage.url

This removes all the functionality of using the class as a page.

- - , , -.

+3

All Articles