7. GEB
Geb is a browser automation solution.
It brings together the power of WebDriver, the elegance of
jQuery content selection, the robustness of Page Object
modelling and the expressiveness of the Groovy language.
8. GEB - Page Object and Module
Geb implements a Page Object pattern via its
Module and Page class (user extends those
classes when creating it own)
Each Page object is consisted of three main
parts:
● Static URL
● Static At
● Static Content
Module represents a reusable unit
of Page content its structure is:
● Static Content
24. How the reality looks like
● Slow
● Unstable
● No standard
● Hard to maintain
○ Refactor
○ To big page objects
○ Developer reluctance
● One repo for everything
● No ownership defined
25. Test Architecture
Test Class Controller Page Object
View Controller Model
Test Class Page Object
GEB/Selenium Yeah Pages
+ Whatever I need + Whatever I need
26. Page Object as Model
Only locators and possibilities
of how to interact with them
33. WebDriver implementation
If your project is Java based
then you might consider use
Groovy and Groovy based
testing frameworks like GEB
and Spock.
Groovy is relatively easy for
Java developers and it brings
to the table lot of magic that
decreases test verbosity
35. WebDriver implementation
Then similar effects you can
obtain using Page Object
pattern, Java 8 default
methods in interfaces with
combination with fluent style
programming.
37. WebDriver implementation - problem
Simple test yet it is not visible
at the first glance
Selectors in a test class..
38. WebDriver implementation - problem
Simple test yet it is not visible
at the first glance
Selectors in a test class..
Test class does everything…
39. WebDriver implementation - problem
Simple test yet it is not visible
at the first glance
Selectors in a test class..
Test class does everything…
It slows down reading speed…
Increases frustration and most
importantly onboarding time of
the new less experienced
team members
40. WebDriver - What we want!
Test written in natural to the user
language, configuration and details
are abstracted away.
41. WebDriver - How To
1. Create abstract BaseTestClass - this class will hold all driver
configuration actions as well as clean up actions
2. Delegate Driver creation to the DriverFactory utility class
42. WebDriver - How To
1. Create abstract BaseTestClass - this class will hold all driver
configuration actions as well as clean up actions
2. Delegate Driver creation to the DriverFactory utility class
44. WebDriver - How To -BasePageClass
3. Create abstract BasePageClass that will have common methods ex. $()
45. WebDriver - How To -BasePageClass
3. Create abstract BasePageClass that will have common methods ex. $()
46. WebDriver - How To -BasePageClass
3. Create abstract BasePageClass that will have common methods ex. $()
47. 4. Create Page class that will
extend BasePageClass
WebDriver - How To
-BasePageClass
48. 4. Create Page class that will
extend BasePageClass
5. Create locator definitions and
methods to operate on them
(see that Page do not consist
any business logic)
WebDriver - How To
-BasePageClass
49. 4. Create Page class that will
extend BasePageClass
5. Create locator definitions and
methods to operate on them
(see that Page do not consist
any business logic)
WebDriver - How To
-BasePageClass
50. 4. Create Page class that will
extend BasePageClass
5. Create locator definitions and
methods to operate on them
(see that Page do not consist
any business logic)
6. Apply method chaining (it is a
one way of fluent style
application)
WebDriver - How To
-BasePageClass
51. 4. Create Page class that will
extend BasePageClass
5. Create locator definitions and
methods to operate on them
(see that Page do not consist
any business logic)
6. Apply method chaining (it is a
one way of fluent style
application)
WebDriver - How To
-BasePageClass
52. 7. Create Interface that will
contain default methods. This
methods should gather actions
in a chain in order to perform a
business logic on the Page.
WebDriver - How To - Controllers
53. 7. Create Interface that will
contain default methods. This
methods should gather actions
in a chain in order to perform a
business logic on the Page.
WebDriver - How To - Controllers
54. 7. Create Interface that will
contain default methods. This
methods should gather actions
in a chain in order to perform a
business logic on the Page.
WebDriver - How To - Controllers
56. Takeaways - Why GEB
● Based on Selenium WebDriver
● Page Object is main focus of the framework
● jQuery style content selection
● Uses Groovy language
● WebDriver is a W3C recommendation
● Easy to start
● Productivity
57. To be honest, good E2E tests can be obtained without
GEB… and having a GEB do not ensure well written E2E
test as previously saw.
Think of the test architecture upfront so you won’t land
with a test suite that has to be refactored to the ground
Takeaways - Why GEB
58. Takeaways - Writing clear tests
● It helps with test maintainability
● It improves readability by providing human
friendly dsl
● It helps with onboarding new team
members
● It encourages reusability
● It is easier to debug if we know at which
step test failed
● It lives room for new testing approaches.