geb: save time with groovy functional testing
DESCRIPTION
This was a presentation I gave in 10/2012 to the DFW Groovy/Grails User Group. The code examples I presented are available at https://github.com/jhamit/geb-examples . Also, there will be additional updates to the examples as I work through them that will be explained on my blog.TRANSCRIPT
![Page 1: Geb: Save Time with Groovy Functional Testing](https://reader033.vdocuments.mx/reader033/viewer/2022051515/54c41f1d4a7959385e8b4577/html5/thumbnails/1.jpg)
Discussion document – Strictly Confidential & Proprietary
Geb:Save Time with Groovy Functional TestingDallas, TXOctober 2012
![Page 2: Geb: Save Time with Groovy Functional Testing](https://reader033.vdocuments.mx/reader033/viewer/2022051515/54c41f1d4a7959385e8b4577/html5/thumbnails/2.jpg)
2October, 2012
Geb: Save Time with Groovy Functional Testing
Agenda …
We will cover how a successful workflow for developing functional tests
• Introductions
• Interactive Shell
– Basic setup
– Syntax Overview
• Page Abstraction
– Overview
– Modules
– Functions
• Functional Testing
• Recap and Questions
![Page 3: Geb: Save Time with Groovy Functional Testing](https://reader033.vdocuments.mx/reader033/viewer/2022051515/54c41f1d4a7959385e8b4577/html5/thumbnails/3.jpg)
3
Introductions
October, 2012
Geb: Save Time with Groovy Functional Testing
![Page 4: Geb: Save Time with Groovy Functional Testing](https://reader033.vdocuments.mx/reader033/viewer/2022051515/54c41f1d4a7959385e8b4577/html5/thumbnails/4.jpg)
4
Interactive Shell
October, 2012
Geb: Save Time with Groovy Functional Testing
![Page 5: Geb: Save Time with Groovy Functional Testing](https://reader033.vdocuments.mx/reader033/viewer/2022051515/54c41f1d4a7959385e8b4577/html5/thumbnails/5.jpg)
5October, 2012
Geb: Save Time with Groovy Functional Testing
Interactive Shell…
Getting started with Geb in the interactive Groovy Shell
• Firefox for Geb
• Try out your tests before putting them into code
• Useful for rapid test development
• http://groovy.codehaus.org/Groovy+Shell
• https://github.com/jhamit/geb-examples
![Page 6: Geb: Save Time with Groovy Functional Testing](https://reader033.vdocuments.mx/reader033/viewer/2022051515/54c41f1d4a7959385e8b4577/html5/thumbnails/6.jpg)
6October, 2012
Geb: Save Time with Groovy Functional Testing
Interactive Shell …
Basic Geb syntax looks familiar, though there are some differences with jQuery
• http://www.gebish.org/manual/current/
Key Objects
• geb.Browser
• geb.navigator.Navigator
• geb.js.JavascriptInterface
Nice Features
• DOM Inspection via CSS Selectors, Indexes, Attributes
• DOM Interaction via b.$.click()
• DOM Manipulation via jQuery Hook
Examples
• b.title
• b.$('div.content-main')
• b.$('div.tweet').first().find('a[href="/improving"]',0)
![Page 7: Geb: Save Time with Groovy Functional Testing](https://reader033.vdocuments.mx/reader033/viewer/2022051515/54c41f1d4a7959385e8b4577/html5/thumbnails/7.jpg)
7
Page Abstraction
October, 2012
Geb: Save Time with Groovy Functional Testing
![Page 8: Geb: Save Time with Groovy Functional Testing](https://reader033.vdocuments.mx/reader033/viewer/2022051515/54c41f1d4a7959385e8b4577/html5/thumbnails/8.jpg)
8October, 2012
Geb: Save Time with Groovy Functional Testing
Page Abstraction …
Define the essence of the page in order to separate the concerns of test methods and web elements
These tools allow flexibility in page design without breaking tests
• Page – Conceptual abstraction of a URLs
• Page Module - Sections that are reusable across multiple pages
• Page Method – Actions that are used frequently on pages
![Page 9: Geb: Save Time with Groovy Functional Testing](https://reader033.vdocuments.mx/reader033/viewer/2022051515/54c41f1d4a7959385e8b4577/html5/thumbnails/9.jpg)
9
Functional Testing
October, 2012
Geb: Save Time with Groovy Functional Testing
![Page 10: Geb: Save Time with Groovy Functional Testing](https://reader033.vdocuments.mx/reader033/viewer/2022051515/54c41f1d4a7959385e8b4577/html5/thumbnails/10.jpg)
10October, 2012
Geb: Save Time with Groovy Functional Testing
Functional Testing…
Geb makes it easy to test natively in multiple browsers
• Faster and easier to develop tests
• Automated report generation
• Easily invoked from command line
• Can be incorporated into build/deployment process
• Point to other environments with native browsers via geb.build.baseUrl
![Page 11: Geb: Save Time with Groovy Functional Testing](https://reader033.vdocuments.mx/reader033/viewer/2022051515/54c41f1d4a7959385e8b4577/html5/thumbnails/11.jpg)
11October, 2012
Geb: Save Time with Groovy Functional Testing
Functional Testing…
More Geb to come so follow along and share your techniques with the community…
More Geb to come…
Follow along @josh_hamit or JoshHamit.com
• Configurable page instances
• Module lists
![Page 12: Geb: Save Time with Groovy Functional Testing](https://reader033.vdocuments.mx/reader033/viewer/2022051515/54c41f1d4a7959385e8b4577/html5/thumbnails/12.jpg)
12
Recap and Questions
October, 2012
Geb: Save Time with Groovy Functional Testing